不同的列表项
嘿,我有一个非常有趣的问题。我有一个非常长的菜单,想要一个具有不同宽度和高度的项目。
菜单看起来像这样:
<ul id="nav">
<li id="smaller"><a href="#" id="smallerLink">The smallest item</a></li>
<li><a href="#">Another item</a></li>
<li><a href="#">Another item</a></li>
<li><a href="#">Another item</a></li>
(...)
</ul>
然后我有类似的内容:
style.css:
#nav {
list-style-type: none;
}
#nav li {
display: inline-block;
line-width: 2em;
width: 20px;
height: 20px;
}
#nav li a {
display: inline-block;
width: 20px;
height: 20px;
}
#smaller {
width: 10px;
height: 10px;
}
#smallerLink {
width: 10px;
height: 10px;
}
为什么第一个项目不是 10x10px?
Hey, I've a very funny problem. I have a very loong ul li a menu and want to have ONE item with different width and height.
The menu looks like this:
<ul id="nav">
<li id="smaller"><a href="#" id="smallerLink">The smallest item</a></li>
<li><a href="#">Another item</a></li>
<li><a href="#">Another item</a></li>
<li><a href="#">Another item</a></li>
(...)
</ul>
Then I have something like in:
style.css:
#nav {
list-style-type: none;
}
#nav li {
display: inline-block;
line-width: 2em;
width: 20px;
height: 20px;
}
#nav li a {
display: inline-block;
width: 20px;
height: 20px;
}
#smaller {
width: 10px;
height: 10px;
}
#smallerLink {
width: 10px;
height: 10px;
}
Why the first item isn't 10x10px?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为它包含一个宽度和高度均为 20px 的 a 标签。在你的#smaller css定义上设置overflow:hidden,然后它应该可以工作。 并使其#nav li#smaller以获得更高的特异性。
Because it contains an a-tag with width and height of 20px. Set overflow:hidden on your #smaller css definition, then it should work. And make it #nav li#smaller for greater specifity.