页脚css制作
页脚基础样式设置
页脚通常固定在页面底部,使用position: fixed或flex布局实现。基础CSS代码如下:
footer {
background-color: #333;
color: white;
text-align: center;
padding: 20px 0;
width: 100%;
}
固定底部布局
使用position: fixed将页脚固定在视口底部:
footer {
position: fixed;
bottom: 0;
left: 0;
z-index: 100;
}
Flex布局全屏页脚
通过Flexbox实现内容不足时页脚仍贴底:
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
main {
flex: 1;
}
footer {
flex-shrink: 0;
}
响应式页脚设计
使用媒体查询适配不同屏幕尺寸:
footer {
padding: 15px;
}
@media (min-width: 768px) {
footer {
padding: 25px;
font-size: 1.1em;
}
}
页脚内容排版
常见多列布局实现方式:
.footer-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
max-width: 1200px;
margin: 0 auto;
}
页脚链接样式
设置链接交互效果:
footer a {
color: #ccc;
text-decoration: none;
transition: color 0.3s;
}
footer a:hover {
color: white;
}
页脚分割线
添加顶部边框增强视觉分离:
footer {
border-top: 1px solid rgba(255,255,255,0.1);
box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
}
动态版权年份
使用JavaScript自动更新年份:

<span id="year"></span>
<script>
document.getElementById('year').textContent = new Date().getFullYear();
</script>






