aiwei笑
2015-09-23 09:24
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>overflow失效妙用</title>
<style type="text/css">
body{background:#ccc;}
.con{width:80%;height:1000px; background:#6CF; margin:0 auto;}
.h0{height:0px;}
.ovh{overflow:hidden;}
.tr{text-align:right;}
.box{width:48px; height:48px; background:#f00;}
.abs{position:absolute;}
.ml10{right:0px;}
.mt30{top:0px;}
</style>
</head>
<body>
<div class="con">
<div class=" h0 0vh tr "> <div class="box abs ml10 mt30" />
</div>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style>
.header {
padding: 10px 0 0;
position: fixed;
width: 300px;
height:50px;
background-color:#000;
opacity: 0.2;
filter:alpha(opacity=20);
}
</style>
</head>
<body>
<div style="position: absolute; left: 0px; top: 100px;">
<div class="header">
</div>
</div>
<div style="height:2000px; background-color: #DEFBFF;"></div>
</body>
</html>
你看看这个是不是你想要的,还有就是你上面的代码有很多错误,虽然运行不出来,但是标签要打全,定义的class也要一致,再好好看看。
position:fixed
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>overflow失效妙用</title>
<style type="text/css">
body{background:#ccc;}
.con{width:80%;height:1000px; background:#6CF; margin:0 auto;}
.h0{height:0px;}
.ovh{overflow:hidden;}
.tr{text-align:right;}
.box{width:48px; height:48px; background:#f00;display:inline;}
.abs{position:absolute;}
.ml10{right:0px;}
.mt30{top:0px;}
</style>
</head>
<body>
<div class="con">
<div class=" h0 0vh tr "> <div class="box abs ml10 mt30" ></div>
</div>
</div>
</body>
</html>
---------------------------------------------------------------------
还是无法实现
你先把自己的代码补全,看看还有打错的没有,仔细检查。
脱离主体,悬浮在窗口右上角,不随滚动栏滚动而消失
你说的不动是什么意思,是随着主体一起还是怎么?
CSS深入理解之absolute
51957 学习 · 254 问题
相似问题