<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
}
main {
flex: 1;
position: relative;
}
nav {
height: 8vh;
background-color: #34495e;
display: flex;
justify-content: space-evenly;
align-items: center;
}
nav a {
text-decoration: none;
font-size: 1.2em;
color: #fff;
opacity: .8;
flex: 1;
text-align: center;
/* text-transform:大小写转换; 文本转换 uppercase:大写的 */
text-transform: uppercase;
}
nav a:nth-child(2) {
border-left: 2px solid #fff;
border-right: 2px solid #fff;
}
main>div {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
transform: translateX(-100%);
transition: 1s;
font-size: 28px;
font-weight: bold;
z-index: 1;
}
main>div:target {
transform: translateX(0px);
}
main>div:nth-of-type(1):target {
background: green;
}
main>div:nth-of-type(2):target {
background: pink;
}
main>div:nth-of-type(3):target {
background: skyblue;
}
body::after {
content: 'HuZhenChu.com';
position: absolute;
top: 50%;
left: 50%;
opacity: .4;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<main>
<div id="home">
胡振楚
</div>
<div id="video">
古小胡
</div>
<div id="live">
楚楚胡
</div>
</main>
<nav>
<a href="#home">home</a>
<a href="#video">video</a>
<a href="#live">live</a>
</nav>
</body>
</html>
实际截图
image.png
网友评论