使用垂直百分比css

编程入门 行业动态 更新时间:2024-10-26 14:39:22
本文介绍了使用垂直百分比css - height:x%;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想为一个应用程序流畅的布局,我有一些麻烦使用css的高度百分比。它正在使用窗口的水平尺寸来指定高度%,当我想它从窗口的垂直尺寸获得这个百分比。这是可能还是我不幸运?

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和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.

推荐答案

如果你使用的是窗口的水平尺寸, JavaScript来更新父节点的绝对高度,height%开始意味着什么。从玩耍,P或DIV作为身体的第一代孩子忽略任何CSS高度%;包装在绝对高度的东西。如果你之前不知道高度,请使用onload JS函数来设置它。

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.

更多推荐

使用垂直百分比css

本文发布于:2023-10-07 23:42:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1470871.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:百分比   css

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!