网页制作模板css


网页制作模板CSS示例
以下是一些常用的网页制作模板CSS代码示例,可用于快速构建响应式、美观的网页布局。
基础全局样式
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Arial', sans-serif;
}
body {
line-height: 1.6;
color: #333;
background-color: #f4f4f4;
}
响应式网格布局
.container {
width: 100%;
max-width: 1200px;
margin: 0 auto;
padding: 0 15px;
}
.row {
display: flex;
flex-wrap: wrap;
margin: 0 -15px;
}
.col {
padding: 0 15px;
flex: 1 0 0%;
}
@media (max-width: 768px) {
.col {
flex: 0 0 100%;
margin-bottom: 20px;
}
}
导航栏样式
.navbar {
background-color: #333;
color: white;
padding: 15px 0;
}
.nav-links {
display: flex;
list-style: none;
}
.nav-links li {
margin-right: 20px;
}
.nav-links a {
color: white;
text-decoration: none;
transition: color 0.3s;
}
.nav-links a:hover {
color: #ddd;
}
按钮样式
.btn {
display: inline-block;
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
text-decoration: none;
transition: background-color 0.3s;
}
.btn:hover {
background-color: #0056b3;
}
.btn-secondary {
background-color: #6c757d;
}
.btn-secondary:hover {
background-color: #5a6268;
}
卡片组件
.card {
background: white;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
padding: 20px;
margin-bottom: 20px;
}
.card-title {
font-size: 1.25rem;
margin-bottom: 15px;
color: #333;
}
.card-body {
color: #666;
}
表单样式
.form-group {
margin-bottom: 15px;
}
.form-control {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}
.form-label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
页脚样式
.footer {
background-color: #333;
color: white;
padding: 30px 0;
text-align: center;
margin-top: 30px;
}
.footer-links {
list-style: none;
display: flex;
justify-content: center;
margin-bottom: 15px;
}
.footer-links li {
margin: 0 15px;
}
.footer-links a {
color: #ddd;
text-decoration: none;
}
.footer-links a:hover {
color: white;
}
这些CSS模板可以组合使用,根据实际需求进行调整和扩展。通过合理运用这些样式,可以快速构建出专业且响应式的网页界面。






