CSS(续)--案例

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>盒子模型案例</title>
<style>
	body{
		margin:0px;
		padding:0px;
		border:1px solid #FF0000;
	}
	div{
		width:100px;
		height:50px;
		border-top:2px #00CC66 dotted;
		border-right:2px #CC6699 solid;
		border-bottom:2px #999900 dashed;
		border-left:2px #CC66CC groove;
	}
</style>
</head>
<body>
	<div>
		盒子模型案例
	</div>
</body>
</html>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>float</title>
<style>
	div{
		width:200px;
		height:120px;
		border:1px #FF0000 solid;
	}
	#one{
		background-color:#0000FF;
		text-align:center;
		float:right;
	}
	#two{
		background-color:#33FFFF;
		text-align:left;
		clear:right;
		float:right;
	}
	#three{
		background-color:#CCFF66;
		text-align:right;
	}
</style>
</head>
<!-- 
	
-->
<body>
	<div id="one">
		第一个div
	</div>
	<div id="two">
		第二个div
	</div>
	<div id="three">
		第三个div
	</div>
</body>
</html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>float</title>
<style>
	#content{
		width:200px;
		height:80px;
		background-color:#FFFFFF;
	}
	#image{
		float:left;
	}
</style>
</head>
<!-- 
	
-->
<body>
	<div id="content">
		<div id="image">
			<img src="1.png" />
			
		</div>
		<div id="text">
			我正在测试代码我正在测试代码我正在测试代码我正在测试代码
		</div>
	</div>
</body>
</html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>position</title>
<style>
	#one{
		width:200px;
		height:80px;
		border:1px #009966 solid;
		background-color:#00CCCC;
		position: relative;
		z-index:10;
	}
	#two{
		width:200px;
		height:80px;
		border:1px #009966 solid;
		background-color:#CC00CC;
		position:absolute;
		top:60px;
		left:40px;
		z-index:5;
	}
	#three{
		width:200px;
		height:80px;
		border:1px #009966 solid;
		background-color:#0000FF;
		position:relative;
		z-index:1;
	}
</style>
</head>
<!-- 
	position:标签的定位
			值:
				absolute	绝对定位
					标签原有的位置释放,下面的标签上移
					偏移时参照的对象为父对象(父标签)
				relative	相对定位
					标签原有的位置不释放
					偏移时参照的对象为对象的原有位置
		偏移属性:
			top:
			left:
			right:
			bottom:
		
		层:
		z-index:
			值大着 上层显示
			值小着, 下层显示
			
			使用前提: 必须设置position

-->
<body>
	<div id="one">
	
	</div>
	<div id="two">
	
	</div>
	<div id="three">
	
	</div>
</body>
</html>

这些代码没有什么难度,把最基本的概念理解了,再多熟练写代码提高代码的书写速度!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值