DIV高度设置为屏幕的百分比? [英] DIV height set as percentage of screen?

查看:168
本文介绍了DIV高度设置为屏幕的百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将父级DIV设置为完全100%屏幕高度的70%。我设置了以下CSS,但它似乎没有做任何事情:

  body {
font-family :Noto Sans,无衬线;
margin:0 auto;
height:100%;
width:100%;
}
.header {
height:70%;
}

出于某种原因,它似乎不工作,是屏幕尺寸的70%。任何建议?

解决方案

尝试使用视口高度



< div {
height:100vh;
}

已经讨论过这里详细


I'm looking to set a parent DIV as 70% of the full 100% screen height. I've set the following CSS but it doesn't seem to do anything:

body {
font-family: 'Noto Sans', sans-serif;
margin: 0 auto;
height: 100%;
width: 100%;
}
.header {
height: 70%;
}

For some reason it doesn't seem to be working though and the header isn't 70% of the screen size. Any advice?

解决方案

Try using Viewport Height

div {
    height:100vh; 
}

It is already discussed here in detail

这篇关于DIV高度设置为屏幕的百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆