当前位置:首页 > CSS

css如何制作成

2026-04-02 01:59:46CSS

使用CSS制作进度条

进度条可以通过HTML和CSS结合创建,以下是几种常见的实现方式:

基础线性进度条

<div class="progress-bar">
  <div class="progress" style="width: 50%;"></div>
</div>
.progress-bar {
  width: 100%;
  height: 20px;
  background-color: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}

.progress {
  height: 100%;
  background-color: #4CAF50;
  transition: width 0.3s ease;
}

动画进度条

.progress {
  animation: progress-animation 2s infinite;
}

@keyframes progress-animation {
  0% { width: 0%; }
  100% { width: 100%; }
}

圆形进度条

<div class="circular-progress">
  <div class="circle"></div>
</div>
.circular-progress {
  width: 100px;
  height: 100px;
  position: relative;
}

.circle {
  width: 100%;
  height: 100%;
  border: 10px solid #e0e0e0;
  border-top: 10px solid #4CAF50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

进度条样式定制

渐变颜色进度条

.progress {
  background: linear-gradient(to right, #ff5f6d, #ffc371);
}

条纹进度条

.progress {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
  background-size: 1rem 1rem;
}

响应式进度条

使用CSS变量控制进度:

<div class="progress-bar">
  <div class="progress" style="--progress: 75%;"></div>
</div>
.progress {
  width: var(--progress);
}

浏览器兼容性提示

对于旧版浏览器,可能需要添加前缀:

css如何制作成

.progress {
  -webkit-transition: width 0.3s ease;
  -moz-transition: width 0.3s ease;
  transition: width 0.3s ease;
}

标签: css
分享给朋友:

相关文章

css字体制作

css字体制作

CSS字体设置基础 在CSS中设置字体主要通过font-family属性实现,可以指定多个字体作为备选。系统会优先使用第一个可用字体。 body { font-family: "Helvetic…

css怎么制作个人主页

css怎么制作个人主页

设计布局结构 使用CSS的Flexbox或Grid布局创建响应式结构。Flexbox适合一维排列(如导航栏),Grid适合二维布局(如整体页面分区)。例如: .container { displ…

css制作

css制作

CSS 基础语法 CSS(层叠样式表)用于描述HTML元素的样式。一个基本的CSS规则由选择器和声明块组成。选择器指定要样式化的HTML元素,声明块包含一个或多个属性-值对,用花括号 {} 包裹。…

css如何制作圆

css如何制作圆

使用 border-radius 属性 通过设置 border-radius 属性可以轻松创建圆角或圆形元素。值为 50% 时,元素会呈现为圆形。 .circle { width: 100p…

css制作按钮

css制作按钮

基础按钮样式 使用CSS创建一个基础按钮需要定义display、padding、background-color和border等属性。以下是一个简单的示例: .button { display:…

css字体制作

css字体制作

使用 @font-face 自定义字体 通过 @font-face 规则引入自定义字体文件(如 .woff, .woff2, .ttf)。需定义字体名称和文件路径: @font-face {…