当前位置:首页 > CSS

css页脚制作

2026-01-08 17:48:30CSS

CSS页脚制作方法

固定定位页脚 使用position: fixed将页脚固定在页面底部,适用于需要始终显示的页脚。

footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 60px;
  background-color: #333;
  color: white;
  text-align: center;
  line-height: 60px;
}

弹性布局页脚 利用Flexbox布局确保页脚在内容不足时仍位于底部。

body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}
main {
  flex: 1;
}
footer {
  background-color: #333;
  color: white;
  padding: 20px;
  text-align: center;
}

响应式页脚设计 使用媒体查询实现不同屏幕尺寸下的页脚适配。

css页脚制作

footer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  padding: 30px;
  background-color: #222;
  color: #fff;
}

@media (max-width: 600px) {
  footer {
    grid-template-columns: 1fr;
  }
}

粘性页脚解决方案 确保页脚在内容较少时仍位于视窗底部。

html {
  height: 100%;
}
body {
  min-height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
}
footer {
  grid-row-start: 2;
  grid-row-end: 3;
  background: #333;
  color: white;
  padding: 20px;
}

页脚内容布局技巧

多列布局 使用CSS Grid或Flexbox创建多栏页脚内容。

css页脚制作

.footer-content {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 1200px;
  margin: 0 auto;
}

社交图标样式 为页脚中的社交图标添加悬停效果。

.social-icons a {
  color: #fff;
  margin: 0 10px;
  font-size: 20px;
  transition: color 0.3s;
}
.social-icons a:hover {
  color: #1da1f2;
}

版权信息样式 突出显示版权信息的样式设计。

.copyright {
  border-top: 1px solid #444;
  padding-top: 20px;
  margin-top: 20px;
  font-size: 14px;
  opacity: 0.8;
}

标签: css
分享给朋友:

相关文章

css网页制作

css网页制作

CSS网页制作基础 CSS(层叠样式表)用于控制网页的视觉表现,包括布局、颜色、字体等。以下是核心知识点: 选择器与样式规则 /* 标签选择器 */ p { color: #333; fo…

css制作三角形

css制作三角形

使用 border 属性创建三角形 通过设置元素的 border 属性可以实现三角形效果。原理是利用边框的交界处形成的斜边。 .triangle { width: 0; height: 0…

网页制作css

网页制作css

CSS 基础语法 CSS(层叠样式表)用于控制网页的样式和布局。基本语法由选择器和声明块组成: 选择器 { 属性: 值; 属性: 值; } 例如: p { color: b…

css如何制作圆

css如何制作圆

使用 border-radius 属性制作圆 通过设置 border-radius 属性为元素添加圆角效果。当 border-radius 的值等于元素宽度和高度的一半时,元素会呈现圆形。 .cir…

制作css

制作css

CSS基础语法 CSS规则由选择器和声明块组成。选择器指向需要设置样式的HTML元素,声明块包含一个或多个用分号分隔的声明。每个声明由属性和值组成,用冒号分隔。 选择器 { 属性: 值;…

css 制作导航

css 制作导航

基础导航栏制作 使用HTML和CSS创建一个水平导航栏。HTML结构通常使用<ul>和<li>标签,CSS负责样式布局。 <nav> <ul clas…