码迷,mamicode.com
首页 > Web开发 > 详细

css折叠样式(4)——div+css布局

时间:2016-07-16 07:15:08      阅读:754      评论:0      收藏:0      [点我收藏+]

标签:css样式   div+css布局   

内容概要:

技术分享



一、div和span

(1)块级标签:div

(2)内联标签:span

如图所示:


技术分享


二、盒模型(重要)


注:可用浏览器的调试工具可查看盒子


(1)margin:盒子外边距


技术分享

(2)padding:盒子内边距(会改变块的大小)


技术分享

(3)border:盒子边框宽度

(4)width:盒子宽度

(5)height:盒子高度


①:外边距和内边距区别:


技术分享


demo.html

<!doctype html>
<html>
	<head>
		<title>Div+Css布局(div+span以及盒模型)</title>
		<meta charset="utf-8">
		<style type="text/css">
		
			body{
				margin:0;
				padding:0;
				background:#C5C1AA;
			}
			div{
				height:500px;
				margin:60px;
				padding:o;
				border:solid 2px black;
				background-color:rgba(255,0,0,0.7);
				}
			div.div1{
				height:400px;
				margin:0 audio;
				border:solid 3px black;
				background-color:rgba(0,0,255,0.7);
			}
			
		
				
				
			
		</style>
	</head>
	<body>
		<div>
			<div class="div1">
				<h1 style="text-align:center;">欢迎登录系统</h1>
				<h4 style="text-align:center;">账号:<input style="text"></h4>
				<h4 style="text-align:center;">密码:<input style="text"></h4>
			</div>
		</div>
	</body>
</html>


②:盒子模型div摆放例子:


技术分享


demo.html

<!doctype html>
<html>
	<head>
		<title>Div+Css布局(div+span以及盒模型)</title>
		<meta charset="utf-8">
		<style type="text/css">
		body{
			margin:0;
			padding:0;
			background-color:rgba(0,0,255,0.3);
		}
		div{
			width:500px;
			height:500px;
			background-color:rgba(250,128,10,0.8);
			margin:0 auto;   /* 使div居中*/


			border:solid black;
		}
		div.div1{
			float:left;   /* 向左排列/*
			background-color:rgba(255,0,0,0.4);
			border:solid blue;
			height:244px;
			width:244px;	
			margin:0;
			padding:0;
		}
		
		</style>
	</head>
	<body>
		<div>
		<div class="div1"></div>
		<div class="div1"></div>
		
		</div>
	</body>
</html>



本文出自 “发酸的牛奶” 博客,转载请与作者联系!

css折叠样式(4)——div+css布局

标签:css样式   div+css布局   

原文地址:http://wengmengkai.blog.51cto.com/9016647/1826819

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!