您的位置:首页 > 其它

height:100%不起作用(无效),div全屏

2015-06-28 18:00 411 查看
当父容器是body时,height:100%不起作用(无效),解决办法:在css代码段中添加

html, body{ margin:0; height:100%; }


实现div全屏的时候需要上面那段代码。

下面给个div全屏的示例:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>全屏div</title>
<style>
html,body {
margin:0;
height:100%;
}
#test {
width:100%;
height:100%;
background-color:#FC0;
}
</style>
</head>

<body>
<div id="test"></div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: