页脚制作 css
页脚基础样式设计
使用CSS为页脚设置基础样式,通常包括背景色、文字颜色、内边距等属性。以下是一个常见的基础样式示例:
footer {
background-color: #333;
color: white;
padding: 20px 0;
text-align: center;
font-size: 14px;
}
页脚布局方式
固定定位页脚适合需要始终显示在视窗底部的场景:
footer {
position: fixed;
bottom: 0;
width: 100%;
}
相对定位页脚适合文档流中的常规布局:

body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
footer {
margin-top: auto;
}
响应式页脚设计
针对不同屏幕尺寸调整页脚布局:
/* 移动端样式 */
@media (max-width: 768px) {
footer {
padding: 15px 10px;
font-size: 12px;
}
}
/* 桌面端样式 */
@media (min-width: 769px) {
footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 25px 50px;
}
}
页脚内容分栏
创建多列页脚布局:

.footer-columns {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
max-width: 1200px;
margin: 0 auto;
}
@media (max-width: 768px) {
.footer-columns {
grid-template-columns: 1fr;
}
}
页脚链接样式
设置页脚中链接的视觉效果:
footer a {
color: #ccc;
text-decoration: none;
transition: color 0.3s;
}
footer a:hover {
color: white;
}
页脚版权信息样式
为版权信息添加特殊样式:
.copyright {
font-size: 12px;
opacity: 0.8;
margin-top: 20px;
border-top: 1px solid rgba(255,255,255,0.1);
padding-top: 20px;
}
页脚社交图标
添加社交媒体图标样式:
.social-icons {
display: flex;
justify-content: center;
gap: 15px;
}
.social-icons a {
display: inline-block;
width: 32px;
height: 32px;
background-color: rgba(255,255,255,0.1);
border-radius: 50%;
text-align: center;
line-height: 32px;
}






