CSS似乎不能将高度设置为父容器的100% [英] CSS can't seem to set height to 100% of parent container
问题描述
我想知道为什么高度:100%的李在这里没有设置高度为ul他们是一个孩子。
http://homecoming.umd.edu/index2.html
?_?
您需要在父元素上设置显式非百分比高度。您目前在< ul>
上还有 height:100%
做任何事情。如果它是工作,你的导航将扩展你的整个页面,因为它的父是你的包装div,包含一堆其他的东西。但是,如果将< ul>
设置为 height:40px
< li> 会依照。
height:100%
显式高度设置在父元素中的某处。如果没有高度被设置为除了百分比之外的任何高度(或者每个父元素一直高达< body>
和< html>
没有 height:100%
设置),那么它将永远不会执行任何操作,因为它没有参考高度。 / p>
I'm wondering why the height: 100% on the li's in this does not set the height to the ul they're a child of.
http://homecoming.umd.edu/index2.html
?_?
You need to set an explicit non-percentage height on a parent element. You currently have height:100%
on your <ul>
, too, which you'll notice isn't doing anything. If it were working, your navigation would expand your whole page, because its parent is your wrapper div that contains a bunch of other stuff. However, if you set your <ul>
to something like height:40px
, the <li>
will follow suit.
height:100%
depends on an explicit height set somewhere in a parent element. If no height is ever set with anything other than percentages (or if every parent element all the way up to <body>
and <html>
doesn't have height:100%
set), then it will never actually do anything, because it has no reference height to start from.
这篇关于CSS似乎不能将高度设置为父容器的100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!