use vertical percentage for css - height: x%;

别说谁变了你拦得住时间么 提交于 2019-12-02 02:27:52

问题


I am trying to make a fluid layout for an app and am having some trouble with using css for height percentages. It is using the horizontal size of the window to specify the height % when I want it to be getting this percentage from the vertical size of the window. Is this possible or am I out of luck?

width: x%;
height: y%;

x and y being the percentage that I want the element to be. Both are being determined by the horizontal size of the window, and I want each to use it's respective axis.


回答1:


If you use JavaScript to update the absolute height of the parent node, height % begins to mean something. From playing around, a P or DIV as first generation child of the body ignores any CSS height%; Wrap it in something with an absolute height. If you don't know the height before hand, use an onload JS function to set it.



来源:https://stackoverflow.com/questions/5129521/use-vertical-percentage-for-css-height-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!