1. 程式人生 > >css-div鋪滿螢幕

css-div鋪滿螢幕

前言

開發地圖時,需要將渲染地圖的div撐滿整個螢幕。操作如下:

程式碼

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible"
content="ie=edge">
<title>Document</title> <style> *{ margin: 0; padding: 0; } div{ height: 100%; width: 100%; position: absolute; background: red; } </style> </head> <body> <div></div> </body>
</html>