求指教 导航栏 页面分辨率问题
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CssTest</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
font-family: "微软雅黑";
color: #fff;
}
body{
background: #000;
}
.head{
width: 100%;
height: 70px;
background: #07cbc9;
position: fixed;
top: 0;
z-index: 3;
}
.logo{
float: left;
}
.head img{
margin-top: 11px;
margin-left: 110px;
}
ul{list-style: none;}
li{
float: left;
width: 110PX;
height: 70px;
line-height: 70px;
text-align: center;
cursor: pointer;
}
li:hover{background: #000;}
.nav{
float: right;
margin-right: 100px;
font-weight: bold;
}
</style>
</head>
<body>
<!-- 顶部 -->
<div class="head">
<div class="logo"><img src="images/logo.png" /></div>
<div class="nav">
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li>GALLERY</li>
<li>FACULTY</li>
<li>EVENTS</li>
<li>CONTACT</li>
</ul>
</div>
</div>
</body>
</html>
正在回答
可以在head里面给Logo和导航嵌套一个大盒子,然后设置大盒子的宽度,在设置margin:0 auto;即可,即:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <!DOCTYPE html> < html > < head > < meta charset = "UTF-8" > < title >CssTest</ title > < style type = "text/css" > * { margin: 0; padding: 0; font-family: "微软雅黑"; color: #fff; } body { background: #000; } .head { width: 100%; height: 70px; background: #07cbc9; position: fixed; top: 0; z-index: 3; } .head-box{ min-width:1400px; margin:0 auto; } .logo { float: left; } .head img { margin-top: 11px; margin-left: 110px; } ul { list-style: none; } li { float: left; width: 110PX; height: 70px; line-height: 70px; text-align: center; cursor: pointer; } li:hover { background: #000; } .nav { float: right; margin-right: 100px; font-weight: bold; } </ style > </ head > < body > <!-- 顶部 --> < div class = "head" > < div class = "head-box" > < div class = "logo" >< img src = "images/logo.png" /></ div > < div class = "nav" > < ul > < li >HOME</ li > < li >ABOUT</ li > < li >GALLERY</ li > < li >FACULTY</ li > < li >EVENTS</ li > < li >CONTACT</ li > </ ul > </ div > </ div > </ div > </ body > </ html > |
希望可以帮到你!
相似问题
登录后可查看更多问答,登录/注册
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧