Html中float简单布局

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			#div1
			{
				width: 100px;
				height: 100px;
				border: 1px solid blue;
				float: left; /* 设置元素浮动 */
			}
			p
			{
				background-color: red;
				clear: both;/* 清除元素浮动 */
			}
			#div2
			{
				width: 100px;
				height: 100px;
				border: 1px solid aqua;
				margin: 0 auto; /* 使层本身在父元素内中居中 */
			}
			
			
			#dvhead
			{
				height: 150px;
				background-color: blue;
				text-align: center;
				
			}
			#dvContent
			{
				background-color: yellow;
				height: 300px;
				
			}
			#dvbottom
			{
				background-color:orange;
				height: 50px;
			}
			#dvleft
			{
				width: 30%;
				height: 100%;
				background-color: red;
				float: left;
			}
			#dvcenter
			{
				background-color: lime;
				width: 70%;
				height: 100%;
				float: left;
			}
		</style>
		
	</head>
	<body>
		<div id="div1"></div>
		<p>这是一个P标签</p>
		<div id="div2"></div>
		<br>
		<div id="dvhead">
			头部
		</div>
		
		<div id="dvContent">
			<div id="dvleft">
			</div>
			<div id="dvcenter">
			</div>
		</div>
		
		<div id="dvbottom">
		</div>
	</body>
</html>
发布了60 篇原创文章 · 获赞 10 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_24432127/article/details/89007138