<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Progress Bar</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #f0f2f5;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.progress-container {
width: 100%;
max-width: 600px;
background-color: #ddd;
border-radius: 8px;
overflow: hidden;
}
.progress-bar {
height: 30px;
background-color: #007bff;
width: 0;
transition: width 0.5s;
color: white;
text-align: center;
line-height: 30px;
}
button {
margin-top: 20px;
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: white;
cursor: pointer;
font-size: 1em;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="progress-container">
<div id="progressBar" class="progress-bar">0%</div>
</div>
<button onclick="increaseProgress()">Increase Progress</button>
<script>
function increaseProgress() {
var progressBar = document.getElementById('progressBar');
var width = parseInt(progressBar.style.width) || 0;
if (width < 100) {
width += 10;
progressBar.style.width = width + '%';
progressBar.textContent = width + '%';
}
}
</script>
</body>
</html>
标签:效果,进度条,color,progressBar,width,background,height,border
From: https://blog.51cto.com/u_16215583/11989331