css 定位

position 把元素放在一个静态的,相对的 绝对的 或者固定的位置中
top 元素向上的偏移量
left 元素向左的偏移量
right 元素向右的偏移量
bottom 元素向下的偏移量
overflow 设置元素溢出其区域发生的事情
clip 设置元素显示的状态
vertical-align 设置元素垂直对齐方式
z-index 设置元素的堆叠顺序

 

<div id="position1"></div>
<div id="position2"></div>

 

#position1{

width: 100px;
height: 100px;
background: green;
/* 相对布局偏移量;*/
position: relative;
/* right: 100px;*/
/* 绝对布局 在页面不占有位子*/
/* position: absolute;*/

/* 固定布局 */
/* position: fixed;*/

/* 静态布局 与相对布局区别 对偏移量不影响*/
/*
position: static;
left: 111px;
*/
z-index: 2;
/* 排在第二层*/
}
#position2{


width: 100px;
height: 100px;
background: orange;

position: relative;
top: -50px;
right: -10px;
z-index: 1;
/* 设置层的高低显示在最前*/
}

posted @ 2015-05-12 14:54  谢小锋  阅读(143)  评论(0)    收藏  举报