我试图让每个标签的高度都达到100%,但它不起作用。
这是我的HTML代码:
<div class="container">
<div class="row">
<div class="twelve columns">
<section>
<h4>Basic Page</h4>
<p>This index.html page is a placeholder with the CSS, font and favicon. It's just waiting for you to add some content! If you need some help hit up the <a href="http://www.getskeleton.com">Skeleton documentation</a>.</p>
</section>
</div>
</div>
</div>
CSS代码:
section {
height: 100%;
background-color: #ccc;
}
skeleton.css和normalize.css已下载
答案 0 :(得分:2)
height: 100%;
与父母的height
相关。这意味着如果您尚未设置未定义的父元素“height
,100%
未定义。”
您需要为height
元素设置明确的.twelve
(如果是%
,则为其父母等等。)
另见:
答案 1 :(得分:1)
您应该将html, body {height: 100%;}
然后将.container
设置为100%,然后将section
的定位设置为绝对值以达到该目标,因为百分比的高度是相对于其父/而计算的容器
您可以将您的部分设置为height: 100vh;
来实现这一目标。请注意填充和边距,因为该部分可能比视口大。 :)
Made a jsbin。 *没有骨架
This是了解css单位的最佳视频。