<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>使用固定定位来实现返回顶部的按钮</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
body{
height: 2000px;
}
a{
width: 40px;
height: 60px;
display: block;
background-color: #ccc;
text-align: center;
line-height: 30px;
text-decoration: none;
color: #fff;
font-weight: bold;
position: fixed;/*使用固定定位*/
bottom: 100px;/*距离下边100px*/
right: 30px;/*距离右边30px*/
}
</style>
</head>
<body>
<a href="#">返回顶部</a>
</body>
</html>
转载请注明:大灰牛博客 » 使用固定定位来实现返回顶部的按钮