用css做一个网页模板
时间: 2024-01-29 09:03:06 浏览: 26
好的,以下是一个简单的基于CSS的网页模板。这个模板使用了Flexbox来进行布局,并使用了一些常见的CSS样式来美化页面。
HTML代码:
```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>网页模板</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>网页模板</h1>
<nav>
<ul>
<li><a href="#">主页</a></li>
<li><a href="#">关于</a></li>
<li><a href="#">联系我们</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2>欢迎来到我们的网站</h2>
<p>这是一个基于CSS的网页模板,可以用来快速创建一个漂亮的网站。</p>
<button>了解更多</button>
</section>
<section>
<h2>我们的服务</h2>
<ul>
<li>网站开发</li>
<li>移动应用开发</li>
<li>UI设计</li>
</ul>
</section>
<section>
<h2>我们的团队</h2>
<ul>
<li><img src="https://via.placeholder.com/150" alt="团队成员1"></li>
<li><img src="https://via.placeholder.com/150" alt="团队成员2"></li>
<li><img src="https://via.placeholder.com/150" alt="团队成员3"></li>
</ul>
</section>
</main>
<footer>
<p>© 2021 网页模板</p>
</footer>
</body>
</html>
```
CSS代码:
```css
/* 全局样式 */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
}
/* 页面结构 */
header {
background-color: #333;
color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
}
nav ul {
list-style: none;
display: flex;
}
nav li {
margin-right: 1rem;
}
nav a {
color: #fff;
text-decoration: none;
}
main {
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem;
}
section {
margin-bottom: 2rem;
text-align: center;
}
section h2 {
font-size: 2rem;
margin-bottom: 1rem;
}
section ul {
list-style: none;
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-top: 1rem;
}
section li {
margin-right: 1rem;
}
section img {
width: 150px;
height: 150px;
object-fit: cover;
border-radius: 50%;
}
button {
background-color: #333;
color: #fff;
border: none;
padding: 0.5rem 1rem;
margin-top: 1rem;
cursor: pointer;
}
button:hover {
background-color: #666;
}
footer {
background-color: #333;
color: #fff;
text-align: center;
padding: 1rem;
}
```
这个模板使用了典型的HTML结构,包括一个头部、主要内容区域和一个底部。CSS样式使用了Flexbox来实现响应式布局,并使用了一些常见的样式,如颜色、字体大小、边距和背景色等来美化页面。