求大神指教,代碼和老師一樣的,為什么我打出來的是這種?。?/h1>


CSS代碼如下:
.nav{height: 40px;}
.nav_left{width:10px;background: url(../img/nav_left.jpg) no-repeat;float: left;height: 40px;}
.nav_mid{width:980px;background: url(../img/nav_bg.jpg)repeat-x;float: left;}
.nav_right{width: 10px;background: url(../img/nav_right.jpg)no-repeat;float: left;height: 40px;
}
}
.nav_mid li {
?? ?float: left;
?? ?list-style-type: none;
?? ?width: 100px;
?? ?font-family: "微軟雅黑";
?? ?text-align: center;
}
CSS代碼如下:
.nav{height: 40px;}
.nav_left{width:10px;background: url(../img/nav_left.jpg) no-repeat;float: left;height: 40px;}
.nav_mid{width:980px;background: url(../img/nav_bg.jpg)repeat-x;float: left;}
.nav_right{width: 10px;background: url(../img/nav_right.jpg)no-repeat;float: left;height: 40px;
}
}
.nav_mid li {
?? ?float: left;
?? ?list-style-type: none;
?? ?width: 100px;
?? ?font-family: "微軟雅黑";
?? ?text-align: center;
}
2017-05-13
不行啊,復制老師的代碼上去都不行。
2017-05-12
因為logo部分的 .logo_left 和 .logo_right 設置了浮動,老師給父級元素設置了固定高度,來解決父級無法自動獲取到高度的問題,但是浮動的影響還在(如果把?.logo的高 height: 80px;去掉,.nav_left會跑到上面去?),只需在?.nav下添加 clear: both; 即可。