这似乎微不足道,我试过
#content { margin-top: 100%;}
JSFiddle
但它不起作用,边距不会占据当前窗口的高度.
解决方法 方案:>你可以使用position:absolute;来实现你的目标.和顶部:100%;
FIDDLE
>第二个选项是添加一个高度为100%的元素; “推”.内容下来FIDDLE
说明:
问题是百分比margin-top(如margin-bottom或padding-top / bottom)是根据父级的宽度计算的.见here
Percentages refer to the wIDth of the containing block
CSS:
body,HTML { background-color: lightblue; height:100%; wIDth:100%; margin:0;}#content { position:absolute; top: 100%; background-color: lightgrey;}
代码选项2:
HTML:
<div ID="push"></div><div ID="content"> <p>... content ...</p></div>
CSS:
body,HTML { background-color: lightblue; height:100%; wIDth:100%; margin:0;}#push{ height:100%;}#content { background-color: lightgrey;}总结
以上是内存溢出为你收集整理的html – 如何设置窗口大小的边距?全部内容,希望文章能够帮你解决html – 如何设置窗口大小的边距?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)