以下是一个简单的 CSS 网站布局模板,你可以根据自己的需要进行修改和定制:
```
/* 头部 */
.parent {
position: relative;
width: 80%;
height: 100%;
}
.header {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 50px;
background-color: #333;
color: #fff;
text-align: center;
font-size: 24px;
}
.header h1 {
margin-top: 0;
margin-bottom: 20px;
}
/* 导航栏 */
.nav {
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 50px;
background-color: #333;
color: #fff;
box-shadow: 0px 0px 10px rgba(0,0,0,0.2);
}
.nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.nav li {
display: inline-block;
margin-right: 10px;
}
.nav li:last-child {
margin-right: 0;
}
.nav li a {
color: #fff;
text-decoration: none;
display: block;
}
.nav li a:hover {
background-color: #222;
}
/* 主体内容 */
.content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 80%;
height: 100%;
}
.content h1 {
margin-top: 0;
margin-bottom: 20px;
}
.content p {
margin-bottom: 20px;
}
.content .image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.content .image img {
width: 100%;
height: auto;
}
.content .video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.content .video loop {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
playsinline;
}
/* 底部 */
.bottom {
position: absolute;
bottom: 0;
left: 50%;
width: 50%;
transform: translateX(-50%);
background-color: #333;
color: #fff;
text-align: center;
font-size: 24px;
}
.bottom p {
margin-bottom: 20px;
}
.bottom a {
color: #fff;
text-decoration: none;
}
.bottom a:hover {
background-color: #222;
}
```
这个模板包括一个 `.parent` 类容器,它的宽度为 80%,高度为 100%。`.header` 类元素是绝对定位,它的高度为 50px,背景色为 #333,文本颜色为 #fff,并且居中对齐。`.nav` 类元素是绝对定位,它的宽度为 100%,高度为 50px,背景色为 #333,color 为 #fff,列表元素 `.nav ul` 的 `li` 元素和列表元素 `.nav li` 的 `a` 元素居中对齐。`.nav li` 元素是水平列表,`a` 元素是悬停导航,当鼠标悬停在导航按钮上时,背景色会变成 #222。`.nav li a` 元素是文本填充,并且没有下划线。`.nav li a:hover` 元素是背景颜色 #222,悬停按钮背景色 #222。`.content` 类元素是绝对定位,它的宽度为 80%,高度为 100%,包含一个 `h1` 标题,一个 `p` 段落和一个 `.image` 图像容器,图像在 100% 的宽度和高度上显示,`.video` 视频容器也是绝对定位,它的宽度为 100%,高度为 100%,并且循环播放。`.bottom` 类元素是相对于底部 `.parent` 元素定位,它的宽度为 50%,高度为 20px,背景色为 #333,文本颜色为 #fff,并且居中对齐。