0

我通常将显示块放在链接上,以使按钮的所有 div 都处于活动状态,而不仅仅是文本。但在这种情况下,我需要使用display:inline-blockinul 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 */
}
4

1 回答 1

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 */
}

演示在http://jsfiddle.net/gaby/mPGDe/1/

于 2013-04-29T13:43:28.337 回答