position:fixedの役割の簡単な紹介

1212 ワード

position:fixedの役割の簡単な紹介:position:fixedはposition:absoluteの強化バージョンと考えられる.絶対位置決めについてはCSSの絶対位置決めを参照してください.position:fixedはposition:absoluteのすべての特徴を持っています.例えば、ドキュメントストリームから離れて、top、left、bottom、rightを使用して位置決めすることができます.独自の特徴は、ある場所に固定できることです.コードの例は次のとおりです.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>    </title>
<style>
*{
  margin:0px;
  padding:0px;
}
body{height:1200px;}
.fixed{
  width:50px;
  height:50px;
  background:green;
  position:fixed;
  left:50px;
  top:200px;
}
.abs{
  width:50px;
  height:50px;
  background:green;
  position:absolute;
  right:50px;
  top:200px;
}
</style>
</head>
<body>
<div class="fixed"></div>
<div class="abs"></div>
</body>
</html>

原文の住所は次のとおりです.http://www.softwhy.com/forum.php?mod=viewthread&tid=17922
詳細については、次の項目を参照してください.http://www.softwhy.com/divcss/