码迷,mamicode.com
首页 > 其他好文 > 详细

div常用技术

时间:2015-05-18 14:39:44      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

1,<div></div>一张图作为背景的用法:

必须指定width,height,background属性

.smallCircle{ margin-top: 25px;  margin-left: 40%; width: 10px;height: 10px; background:url(../images/smallCirlce.png) no-repeat;}

2,div 里面的元素们都居中布局。

.fdiv{margin: 0 auto;width: 998px;height: 462px;}

3,用position: relative 准确定位

.navbg{height: 100px; position: relative; top: -12px;background: url(../images/nav_02.png) no-repeat center top;}

4,父元素相对定位,子元素绝对定位,可以使子元素相对于父元素定位,right是相对于父元素的。

.container
{
	position:relative;
	width:500px;
	height: 20px;
	background-color: antiquewhite;
	left: 50px;
}
.right
{
	position:absolute;
	right:0px;
	width:300px;
	background-color:#b0e0e6;
}
</style>
</head>

<body>
<div class="container">
	<div class="right">
	<p><b>注释:</b>当使用 position 属性进行对齐时,请始终包含 !DOCTYPE 声明!如果省略,则会在 IE 浏览器中产生奇怪的结果。</p>
	</div>
</div>

  

div常用技术

标签:

原文地址:http://www.cnblogs.com/as3lib/p/4511673.html

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