CSS - 清除修复不起作用

时间:2013-03-22 13:11:36

标签: css clearfix

我正在对父(ul)应用明确的修复,但它不起作用

设置display:block;到a,那么明确的修复工作,但为什么? here

中的代码

HTML

<nav>
 <ul class="hmenu main-menu group">
   <li><a href="#" class="active">home</a>
   <li><a href="#">services</a>
   <li><a href="#">pricing</a>
   <li><a href="#">portfolio</a>
   <li><a href="#">blog</a>
   <li><a class="no-border last-menu-item" href="#">contact</a>
  </ul>
 </nav>
 <span>sadfsdafsdaf</span>

CSS

.group:after {
     visibility: hidden;
     display: block;
     font-size: 0;
     content: " ";
     clear: both;
     height: 0;
     }
.group { display: inline-block; }
/* start commented backslash hack \*/
* html .group { height: 1%; }
.group { display: block; }
/* close commented backslash hack */
/*
.group:after {
 content: ""; display: table; clear: both; }
*/

.hmenu li{
 float: left;
 display: inline;
 list-style-type: none;
}
a{
 text-decoration:none;
}


.main-menu{
 width: 940px;
 padding: 0;
 border-top:1px solid #4d4d4d;
  background:#3c3c3c;
}
.main-menu a{
 color: #fff;
/*display:block;*/
 padding: 20px 30px;
 border-right:1px solid #5b5b5b;
}
a.last-menu-item{
 margin-right:181px;

}
.main-menu a.active{
 background:#000;
}
a.no-border{
 border: none;
}
a.lang{
 padding:20px 11px;
}
span{padding:10px 10px;
  margin:20px 30px;
background:red;
height:100px;}

2 个答案:

答案 0 :(得分:0)

尝试设置

display: inline-block;

为跨度

答案 1 :(得分:0)

锚点上的填充不适用,因为锚标记是内联显示的,因此当您将锚点设置为显示块时,填充适用。