css: ul li ul li 高度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7909004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:00:49  来源:igfitidea点击:

css: ul li ul li height

csshtml-lists

提问by Vyacheslav Loginov

I want to set the height for the Games menu like all the other menus, but it is not working. What is wrong?

我想像所有其他菜单一样设置游戏菜单的高度,但它不起作用。怎么了?

This is my code:

这是我的代码:

<ul class="menu">
   <li class="item-474 current active"><a href="/">News</a></li>
   <li class="item-482 deeper parent">
      <span class="separator">Applications</span>
      <ul>
         <li class="item-483"><a href="games.html">Games</a></li>
      </ul>
   </li>
   <li class="item-484"><span class="separator">Appearence</span></li>
</ul>

 

 

#left-menu ul.menu {
  display: block;
  list-style-type: none;
  margin-left: -40px;
}

#left-menu ul.menu li {
  display: block;
  text-align: center; 
  background: url("img/menu1.png");
  width: 208px;
  height: 31px;
  text-align: center;
  list-style-type: none;
  padding: 0px;
  margin: 0px;
}

#left-menu ul.menu li ul li {
  display: block;
  text-align: center; 
  background: url("img/menu2.png");
  width: 208px;
  height: 31px;
  text-align: center;
  list-style-type: none;
}

This is the result:

这是结果:

enter image description here

在此处输入图片说明

回答by Alexey Ivanov

Problem is that li's have fixed height. So when you add second level list there is no space for them.

问题是 li 的高度是固定的。因此,当您添加二级列表时,它们没有空间。

Change height to min-height and everything will works.

将高度更改为最小高度,一切都会正常。

Example: http://jsfiddle.net/FJV8b/

示例:http: //jsfiddle.net/FJV8b/