<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="width: 50px;height: 50px;background-color: black;color:white;
position: fixed; <!--固定在页面的某个位置-->
bottom:20px;
right:20px;
">返回顶部</div>
<div style="height: 5000px;background-color: #dddddd;"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.pg-header{
height: 48px;
background-color: black;
color: #dddddd;
position: fixed;
top:0;
left:0;
right:0;
}
.pg-body{
background-color: #dddddd;
height: 5000px;
}
</style>
</head>
<body>
<div class="pg-header" style="margin-top:2px">头部</div>
<div class="pg-body" style="margin-top:61px;">内容</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="position: relative;width: 500px;height: 200px;border: 1px solid red; margin:0 auto">
<div style="position: absolute;left:0;bottom:0;width:50px;height: 50px;background-color:black;"> </div>
</div>
<div style="position: relative;width: 500px;height: 200px;border: 1px solid red; margin:0 auto">
<div style="position: absolute;right:0;bottom:0;width:50px;height: 50px;background-color:black;"> </div>
</div>
<div style="position: relative;width: 500px;height: 200px;border: 1px solid red; margin:0 auto">
<div style="position: absolute;left:0;top:0;width:50px;height: 50px;background-color:black;"> </div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="z-index:10;
position:fixed;
top:50%;
left:50%;
margin-left: -250px;margin-top:-200px;
background-color:white;
height: 400px;
width:500px;
">
老夫的少女心啊
</div>
<div style="z-index:9; position: fixed;background-color: #dddddd;
top:0;
bottom:0;
right:0;
left:0;
opacity:0.5; <!--设置透明度-->
"></div>
<div style="z-index:8;height:5000px;background-color: red;">
adfads
</div>
</body>
</html>
overflow
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="height: 200px;width: 300px;overflow: auto">
<!--overflow: hidden超出隐藏,auto出现滚动条-->
<img src="萤火虫.jpg">
</div>
</body>
</html>
hover
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.pg-header{
position: fixed;
right:0;
left:0;
top:0;
height: 48px;
background-color:#2459a2;
line-height: 48px;
}
.pg-body{
margin-top: 50px;
}
.w{
width: 980px;
margin: 0 auto;
}
.pg-header .menu:hover{
background-color: blue;
}
.pg-header .menu{
display: inline-block;
padding: 0 10px; <!--0是上下,10是左右-->
color: white;
}
</style>
</head>
<body>
<div class="pg-header">
<div class="w">
<a class="logo">LOGO</a>
<a class="menu">全部</a>
<a class="menu">全部1</a>
<a class="menu">全部2</a>
<a class="menu">全部3</a>
</div>
</div>
<div class="pg-body">
<div class="w">a</div>
</div>
</body>
</html>
background-image
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="background-image:url('萤火虫.jpg');height:180px; background-repeat: no-repeat;">
<!--no-repeat不重复,repeat-x水平重复,repeat-y垂直方向重复-->
</div>
</body>
</html>
小案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="height: 35px;width: 400px;position: relative;">
<input type="text" style="height: 35px;width: 370px;padding-right:30px;" />
<span style="position:absolute;right:0;top:10px;background-image: url(萤火虫.jpg);height: 20px;width: 20px;display:inline-block;"></span>
</div>
</body>
</html>