不同的列表项

发布于 2024-09-15 17:09:55 字数 804 浏览 2 评论 0原文

嘿,我有一个非常有趣的问题。我有一个非常长的菜单,想要一个具有不同宽度和高度的项目。

菜单看起来像这样:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日 2024-09-22 17:09:57

因为它包含一个宽度和高度均为 20px 的 a 标签。在你的#smaller css定义上设置overflow:hidden,然后它应该可以工作。 并使其#nav li#smaller以获得更高的特异性。

#nav li#smaller {
    width: 10px;
    height: 10px;
    overflow: hidden
}

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.

#nav li#smaller {
    width: 10px;
    height: 10px;
    overflow: hidden
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文