猿问

我的导航栏不居中显示

慕哥2479039
浏览 2133回答 7
7回答

一朵大白天

导航栏的div必须有固定宽度才能把margin属性设置成 0 auto,或者把导航栏父元素设置固定宽度,导航栏自己只设置margin属性 0 auto 也可以~

_bug终结者_

代码呢?

ajsdhkads

.nav{clear:both;height:40px;margin:0 auto;width:100%;}

依韵S1

导航外面的div  margin:0 auto; 建议百度一下具体效果

慕哥2479039

 还是不行.nav{ clear:both; height:40px; margin:0 auto;}.nav_left{ width:10px; background:url(../images/images/nav_left.jpg) no-repeat; float:left; height:40px;}.nav_mid{ width:980px; background:url(../images/images/nav_bg.jpg) repeat-x; float:left;}.nav_right{ width:10px; background:url(../images/images/nav_right.jpg) no-repeat; float:left; height:40px;}.nav_mid_left,.nav_mid_right{ float:left; display:inline; }.nav_mid_left{ width:680px;}.nav_mid_right{ width:300px;}.nav_mid_left li{ float:left; list-style-type:none; width:100px; text-align:center; line-height:40px;}.nav_mid a;link,.nav_mid a:visited{ font-size:16px; color:#FFF; text-decoration:none;}.nav_mid a;hover,.nav_mid a:active{ font-size:16px; color:#FF0; text-decoration:none;}

一瞬儿光

marign:0 auto;
随时随地看视频慕课网APP
我要回答