css如何制作成
使用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);
}
浏览器兼容性提示
对于旧版浏览器,可能需要添加前缀:

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





