当前位置:首页 > CSS

css线条特效制作

2026-03-12 08:50:36CSS

CSS线条特效制作方法

基础线条动画 使用borderbackground属性配合animation实现简单线条动态效果:

.line-effect {
  height: 2px;
  background: linear-gradient(90deg, transparent, #3498db, transparent);
  animation: shine 2s infinite;
}
@keyframes shine {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

悬停下划线扩展 创建鼠标悬停时扩展的下划线效果:

.hover-underline {
  position: relative;
}
.hover-underline::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 50%;
  background-color: #e74c3c;
  transition: width 0.3s ease, left 0.3s ease;
}
.hover-underline:hover::after {
  width: 100%;
  left: 0;
}

SVG线条动画 结合SVG实现更复杂的路径动画:

<svg class="svg-line" viewBox="0 0 100 2">
  <path d="M0 1 H100" stroke="#9b59b6" stroke-width="2" stroke-dasharray="100" stroke-dashoffset="100"/>
</svg>
.svg-line {
  width: 100%;
  height: 2px;
}
@keyframes dash {
  to { stroke-dashoffset: 0; }
}
.svg-line path {
  animation: dash 1.5s forwards;
}

多段线条组合 通过伪元素创建分段的装饰线条:

.decorative-line {
  position: relative;
  padding: 20px 0;
}
.decorative-line::before,
.decorative-line::after {
  content: '';
  position: absolute;
  height: 1px;
  width: 40%;
  background: linear-gradient(to right, transparent, #2ecc71);
}
.decorative-line::before {
  top: 0;
  left: 0;
}
.decorative-line::after {
  bottom: 0;
  right: 0;
}

3D立体线条效果 使用box-shadowtransform模拟3D效果:

.line-3d {
  height: 4px;
  background: #f39c12;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transform: perspective(100px) rotateX(10deg);
}

虚线动画 创建动态滚动的虚线效果:

.dashed-line {
  height: 2px;
  background: repeating-linear-gradient(90deg, #3498db, #3498db 10px, transparent 10px, transparent 20px);
  animation: scroll 1s linear infinite;
}
@keyframes scroll {
  0% { background-position: 0 0; }
  100% { background-position: 20px 0; }
}

线条加载指示器 制作进度指示动画:

css线条特效制作

.loader-line {
  height: 4px;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.loader-line::before {
  content: '';
  position: absolute;
  height: 100%;
  width: 50%;
  background: #3498db;
  animation: loading 2s ease-in-out infinite;
}
@keyframes loading {
  0% { left: -50%; }
  100% { left: 150%; }
}

分享给朋友:

相关文章

简单css特效制作

简单css特效制作

CSS 文字阴影效果 为文字添加阴影效果可以通过 text-shadow 属性实现。该属性接受水平偏移、垂直偏移、模糊半径和颜色值。 .text-shadow { text-shadow: 2p…

css特效制作

css特效制作

CSS 特效制作方法 CSS 特效可以通过多种方式实现,以下是一些常见且实用的特效制作方法: 文字阴影效果 使用 text-shadow 属性为文字添加阴影效果,可以设置多个阴影层叠: .te…

vue实现线条动画效果

vue实现线条动画效果

Vue 实现线条动画效果 在 Vue 中实现线条动画效果可以通过多种方式完成,以下是几种常见的方法: 使用 SVG 和 CSS 动画 SVG 是创建线条动画的理想工具,结合 CSS 动画可以实现平滑…

简单css特效制作

简单css特效制作

文字阴影效果 为文字添加阴影效果,增强视觉层次感。通过 text-shadow 属性实现,参数依次为水平偏移、垂直偏移、模糊半径和颜色。 .text-shadow { text-shadow…

css特效制作广告

css特效制作广告

CSS特效制作广告的方法 动画效果 使用@keyframes创建动画,结合transform和opacity属性实现渐变、旋转或缩放效果。例如: @keyframes fadeIn { fr…