就像上面的人提到的那样,它与相对位置有关。但是,为了使其保持静止,您必须制作一个浮动的 div,并且它不是正常内容布局的一部分。
这是一个示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Example</title>
<style>
body, html {padding: 0; margin: 0;}
#wrapper {width: 960px;margin: 0 auto;}
.floater {height: 100%; width: 100%;position: absolute;}
.inner-float {position: relative; width: 1020px; margin: 0 auto;text-align: center;}
.inner-float img {width: 150px; top: -10px; right: 0px;position: absolute;}
.content {}
</style>
</head>
<body>
<div class="floater">
<div class="inner-float">
<img src="./clipboard_icon.png" />
</div>
</div>
<div id="wrapper">
<div class="content">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
</div>
</body>
</html>
希望这可以帮助。
-e