我通常将显示块放到链接中,使按钮的所有div都处于活动状态,而不仅仅是文本。但在这种情况下,我需要使用display:inline-block
ul
中的li
,我认为这会禁用其他显示块?如何让所有li
处于活动状态而不仅仅是文本内部?
以下是示例:http://jsfiddle.net/mPGDe/
HTML:
<ul class="menu">
<li><a href="#">first</a></li>
<li><a href="#">second</a></li>
<li><a href="#l">third</a></li>
</ul>
CSS:
ul {
margin:40px auto;
list-style-type:none;
padding:0;
text-align: center;
}
ul li {
position: relative;
padding: 7px 17px;
margin-right: 10px;
background-color: #f2f2f2;
display: inline-block; /* does it disable display block? */
}
ul li a {
display:block;/* usually to make active all the zone, but here it does not work */
}
答案 0 :(得分:1)
将填充放在a
而不是li
ul li {
position: relative;
margin-right: 10px;
background-color: #f2f2f2;
display: inline-block; /* does it disable display block? */
}
ul li a {
padding: 7px 17px;
display:block;/* usually to make active all the zone, but here it does not work */
}
演示