页脚制作 css
页脚基础样式设置
页脚通常固定在页面底部,包含版权信息、链接等内容。基础CSS样式如下:
footer {
background-color: #f8f9fa;
padding: 20px 0;
text-align: center;
font-size: 14px;
color: #6c757d;
border-top: 1px solid #e9ecef;
}
固定底部页脚
对于内容不足一屏的页面,使用以下代码使页脚始终固定在底部:
html, body {
height: 100%;
}
body {
display: flex;
flex-direction: column;
}
main {
flex: 1 0 auto;
}
footer {
flex-shrink: 0;
}
响应式页脚布局
创建适应不同屏幕尺寸的多列页脚布局:
.footer-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 30px;
max-width: 1200px;
margin: 0 auto;
padding: 0 15px;
}
.footer-column h3 {
margin-bottom: 15px;
color: #212529;
}
.footer-column ul {
list-style: none;
padding: 0;
}
.footer-column li {
margin-bottom: 10px;
}
@media (max-width: 768px) {
.footer-container {
grid-template-columns: 1fr;
}
}
页脚链接样式
为页脚中的链接添加悬停效果:
.footer-link {
color: #6c757d;
text-decoration: none;
transition: color 0.3s ease;
}
.footer-link:hover {
color: #0d6efd;
text-decoration: underline;
}
页脚社交图标
添加社交媒体图标样式:
.social-icons {
display: flex;
justify-content: center;
gap: 15px;
margin-top: 20px;
}
.social-icon {
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #e9ecef;
display: flex;
align-items: center;
justify-content: center;
transition: background-color 0.3s ease;
}
.social-icon:hover {
background-color: #0d6efd;
color: white;
}
页脚版权信息
版权信息的典型样式:
.copyright {
margin-top: 20px;
font-size: 12px;
opacity: 0.7;
}






