[英]Making 2nd level ul 100% height of the first ul instead of the parent li
I have this menu http://codepen.io/alexandernst/pen/oxpGYQ (tried to insert it here but SO's result viewer is breaking the demo...) and I want to make the second and third level ul
elements the same height as the first level ul
and also start at the same position (which would be top: 0
is this concrete demo) as the first ul element.我有这个菜单http://codepen.io/alexandernst/pen/oxpGYQ (试图在这里插入它,但结果查看器正在破坏演示......)我想让第二级和第三级
ul
元素具有相同的高度作为第一级ul
并且也从与第一个 ul 元素相同的位置(这将是top: 0
是这个具体演示)开始。
So, said with other words, I want all ul
elements to start at the tom of the row
div and have 100% height.因此,换句话说,我希望所有
ul
元素都从row
div 的开始处开始并具有 100% 的高度。
Note that I don't know how many li
elements I'll have, so I can't hardcode top
values for each ul
element in order to adjust it's top
position.请注意,我不知道我将拥有多少个
li
元素,因此我无法对每个ul
元素的top
值进行硬编码以调整其top
位置。
I'd like to avoid having to use javascript, but if there is no other way I could accept an answer with JS.我想避免使用 javascript,但如果没有其他方法,我可以接受 JS 的答案。
Try giving position static
to the li
elements.尝试为
li
元素赋予位置static
。 Then when setting height: 100%
to the ul
element it be will relative to the parent ul
instead of the parent li
.然后,当将
height: 100%
设置为ul
元素时,它将相对于父ul
而不是父li
。 So long as the ul
element has position set to relative
, absolute
or fixed
.只要
ul
元素的位置设置为relative
, absolute
或fixed
。
Add this CSS添加这个 CSS
#cssmenu ul li {
position: static !important;
}
#cssmenu ul ul {
top: 0;
height: 100%;
background: #1b9bff;
}
Here is the Codepen solution: http://codepen.io/anon/pen/KzZXxv这是 Codepen 解决方案: http ://codepen.io/anon/pen/KzZXxv
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.