当父容器是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>

 

相关文章:

  • 2021-12-06
  • 2021-09-25
  • 2022-01-17
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-24
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案