李的活动区域

时间:2013-04-29 13:40:19

标签: css html-lists

我通常将显示块放到链接中,使按钮的所有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 */
}

1 个答案:

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

http://jsfiddle.net/gaby/mPGDe/1/

演示