search

Home  >  Q&A  >  body text

The width and height of the div in the body are set to 100%, and the div is not displayed.

<!Doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>test</title>
		<style>
			*{margin:0;padding:0;}
			body{background: green;}
			#main{width:100%;
				height:100%;
				background: yellow;
				margin-top:50px;
				}
		</style>
	</head>
	
	<body>
		<div id="main">
		</div>
	</body>

</html>

After adding the header declaration <!Doctype html>, the div cannot be displayed. After removing it, it can be displayed normally. The same situation occurs when tested in IE11 and chrome browsers. What is the problem?

朝花夕逝朝花夕逝2558 days ago1157

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-12-01 21:19:07

    You can see it by adding a border to main

    reply
    0
  • Cancelreply