DIV CSS left right top bottom定位
2014-11-15 17:08
495 查看
这四个CSS属性样式用于定位对象盒子,必须定义position属性值为absolute或者relative此取值方可生效。
一、语法结构 -
Left、right、top、bottom后跟数字+html单位。
示范结构
div{left:20px}
div{right:20px}
div{top:20px}
div{bottom:20px}
Left 靠左距离多少
Right 靠右边距离多少
Top 距离顶部距离多少
Bottom距离下边距离多少
二、使用条件 -
通常单独使用left、right、top、bottom均无效,需要在使用绝对定位CSS position样式才能生效。
一般left和right在一个样式是只能使用其一,不能left和right都设置,要么使用left就不使用right,要么使用right就不使用left,如果left和right均使用将会出现兼容问题,一个对象设置了靠左left多少距离,自然右边距离自然就有了所以无需设置左边。
相同道理,top和bottom对一个对象只能使用其一,不然会出现逻辑兼容问题。譬如一个人让你往左走,一个人让你往右走,同时发出往左往右走这个时候你也不好判断往那边走。
三、绝对定位中使用 -
一般left、right、top、bottom使用于配合position定位对象位置。大家可以进入CSS position教程篇了解学习这些样式属性。
一、语法结构 -
TOP
Left、right、top、bottom后跟数字+html单位。示范结构
div{left:20px}
div{right:20px}
div{top:20px}
div{bottom:20px}
Left 靠左距离多少
Right 靠右边距离多少
Top 距离顶部距离多少
Bottom距离下边距离多少
二、使用条件 -
TOP
通常单独使用left、right、top、bottom均无效,需要在使用绝对定位CSS position样式才能生效。一般left和right在一个样式是只能使用其一,不能left和right都设置,要么使用left就不使用right,要么使用right就不使用left,如果left和right均使用将会出现兼容问题,一个对象设置了靠左left多少距离,自然右边距离自然就有了所以无需设置左边。
相同道理,top和bottom对一个对象只能使用其一,不然会出现逻辑兼容问题。譬如一个人让你往左走,一个人让你往右走,同时发出往左往右走这个时候你也不好判断往那边走。
三、绝对定位中使用 -
TOP
一般left、right、top、bottom使用于配合position定位对象位置。大家可以进入CSS position教程篇了解学习这些样式属性。
相关文章推荐
- DIV CSS left right top bottom定位
- DIV绝对定位 position、z-index、top、right、bottom和left属性
- css中定位position、偏移top,bottom,left,right和高宽度设置问题
- div+css - CSS标准 - 8.3 Margin properties: 'margin-top', 'margin-right', 'margin-bottom', 'margin-left', and 'margin' - 8.3边距属性
- css div margin-top 无法定位
- left right top bottom定位div无效
- css left right top bottom定位
- css absolute同时设置top,bottom确定div的高度
- css中absolute定位的top bottom left right
- CSS之Background-Position left right center top buttom属性
- CSS---关于内层DIV设置margin-top不起作用的解决方案
- DIV+CSS position定位方法的使用
- div+css的引用形式+定位+浮动
- div+css详解定位与定位应用
- css+div绝对定位
- CSS中DIV定位
- div css sprites精灵-CSS图像拼合 CSS贴图定位网页背景素材图片拼合定位布局技术教程
- css div定位详解
- div+css基础——5.采用div定位技术对div进行排版(相对定位)
- css div设置positon:relative之后,再设置top,div的原位置有空白,解决办法