日期:2014-05-16  浏览次数:20569 次

CSS 常用定位

?

1.居中兼容

.Untitled{

? ? position: absolute;

? ? width: 850px;

? ? height: 768px;

? ? margin-left:-425px;

? ? top:0px;

? ? left:50%;

? ? z-index: 999;

? ? filter: alpha(opacity=0);

? ? opacity:0/100;

? }

实现:红色标注就是实现4要素;

?

2.浮动层固定位

1.外包围法

?

?

html, body {

? ? ? height: 100%;

? ? ? overflow: auto;

? }

? .wrapper { ?//替代body为滚动条

? ? ? position: relative;

? ? ? width: 100%;

? ? ? height: 100%;

? ? ? overflow: auto;

? }

? .box {

? ? ? position: fixed;

? ? ? right: 20px;

? ? ? bottom: 80px;

? }

? html .box {

? ? ? position: absolute; ? ? ? ? ? ? ?//兼容IE

? }

?

<div class="wrapper">?

?</div>

?

<div class="box"><a href="#content" style="float:right;">返回顶部</a></div>

2.兼容法

?

#tbox{

width:47px; height:73px; float:right; position:fixed;