申明为fixed,不管屏幕如何滚动,申明fixed的元素都不会滚动。脱离文档流 可以通过left、top、right、bottom来进行规定
<html>
<head>
<style type="text/css">
div{
/*系统默认是static,表示没有定位,忽略top,bottom,left,right*/
position:fixed;
background-color:#ff0000;
border:3px solid #73AD21;
top:50px;
}
</style>
<title>test</title>
</head>
<body>
<p>title</p>
<div>
content
</div>
<p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p>
</body>
</html>