parent
c4b416893c
commit
370b9abe96
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<title>02-progress-steps</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="container">
|
||||
<div class="bar-wrapper">
|
||||
<span class="bar"></span>
|
||||
<span class="bar"></span>
|
||||
<span class="bar"></span>
|
||||
</div>
|
||||
|
||||
<div class="number-container">
|
||||
<span class="number active">1</span>
|
||||
<span class="number">2</span>
|
||||
<span class="number">3</span>
|
||||
<span class="number">4</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="button-wrapper">
|
||||
<button class="btn" id="prev" onclick="prev()" disabled>Prev</button>
|
||||
<button class="btn" id="next" onclick="next()">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -0,0 +1,53 @@
|
||||
let currentStep = 1;
|
||||
const numbers = document.querySelectorAll(".number");
|
||||
const bars = document.querySelectorAll(".bar");
|
||||
|
||||
const prev = () => {
|
||||
currentStep--;
|
||||
|
||||
if (currentStep < 1) {
|
||||
currentStep = 1;
|
||||
}
|
||||
|
||||
update();
|
||||
};
|
||||
|
||||
const next = () => {
|
||||
currentStep++;
|
||||
|
||||
if (currentStep > 4) {
|
||||
currentStep = 4;
|
||||
}
|
||||
|
||||
update();
|
||||
};
|
||||
|
||||
function update() {
|
||||
numbers.forEach((number, index) => {
|
||||
if (index < currentStep) {
|
||||
number.classList.add("active");
|
||||
} else {
|
||||
number.classList.remove("active");
|
||||
}
|
||||
});
|
||||
|
||||
bars.forEach((bar, index) => {
|
||||
if (index < currentStep - 1) {
|
||||
bar.classList.add("active-bar");
|
||||
} else {
|
||||
bar.classList.remove("active-bar");
|
||||
}
|
||||
});
|
||||
|
||||
if (currentStep > 1) {
|
||||
document.getElementById("prev").disabled = false;
|
||||
} else {
|
||||
document.getElementById("prev").disabled = true;
|
||||
}
|
||||
|
||||
if (currentStep < 4) {
|
||||
document.getElementById("next").disabled = false;
|
||||
} else {
|
||||
document.getElementById("next").disabled = true;
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.container,
|
||||
.number-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.number-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.number {
|
||||
background: #fff;
|
||||
width: 30px;
|
||||
text-align: center;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
border: 4px solid #c4c4c4;
|
||||
line-height: 30px;
|
||||
transition: border-color 0.3s ease-in;
|
||||
}
|
||||
|
||||
.active {
|
||||
border-color: rgb(21, 95, 255);
|
||||
}
|
||||
|
||||
.bar-wrapper {
|
||||
position: absolute;
|
||||
height: 5px;
|
||||
width: 300px;
|
||||
top: 50%;
|
||||
display: flex;
|
||||
transform: translateY(-50%);
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.bar {
|
||||
width: calc(100% / 3);
|
||||
display: block;
|
||||
height: 5px;
|
||||
background: #c4c4c4;
|
||||
transition: background-color 0.3s linear;
|
||||
}
|
||||
|
||||
.active-bar {
|
||||
background-color: rgb(21, 95, 255);
|
||||
}
|
||||
|
||||
.button-wrapper {
|
||||
margin-top: 10px;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background-color: rgb(21, 95, 255);
|
||||
color: #ffffff;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
padding: 10px 15px;
|
||||
border: unset;
|
||||
border-radius: 5px;
|
||||
margin: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
background-color: #c4c4c4;
|
||||
}
|
Loading…
Reference in new issue