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

DIV的属性

时间:2015-10-01 15:18:17      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

一、常用属性

1、Height:设置DIV的高度;Width:设置DIV的宽度。

2、margin:用于设置DIV的外延边距,也就是到父容器的距离。margin:后面跟有四个距离分别为到父容器的上-右-下-左边的距离;margin: [top][right][bottom][left]

 可以分别设置:margin-left:到父容器左边框的距离;margin-right:到父容器右边框的距离;margin-top: 到父容器上边框的距离;margin-bottom:到父容器下边框的距离。

3、padding:用于设置DIV的内边距(内如子元素与DIV边界的距离)。padding:后面跟有四个距离分别为到父容器的上-右-下-左边的距离;margin: [top][right][bottom][left]:需要注意的是padding设置的距离不包括在本身的width和height内(在IE7和FF中),比如一个DIV的width设置了100px,而padding-left设置了50px,那么这个DIV在页面上显示的将是150px宽。

4、border:设置DIV的边框样式;display:设置显示属性。其值有block、none;float:设置DIV在页面上的流向,其值有left(靠左显示)、right(靠右显示)、none;

background:设置DIV的背景样式;background后可直接跟背景的颜色、背景图片、平铺方式等样式。也可以用以下属性分别设置。

  background-color:设置背景颜色;background-attachment:背景图像的附加方式,其值有scroll、fixed; background-image:指定使有的背景图片;background-repeat:背景图象的平铺方式。其值有no-repeat(不平铺)、repeat(两个方向平铺)、repeat-x(水平方向平铺)、repeat-y(垂直方向平铺); background-position:在DIV中定位背景位置。其值有top bottom left right的不同组合。也可以以用坐标指定具体的位置。

5、position指定为absolute。

4、opacity 透明度 filter:alpha(opacity=value)  eg:filter:alpha(opacity=50);opacity:0.5;

DIV的属性

标签:

原文地址:http://www.cnblogs.com/yangxu6069/p/4851017.html

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