<div class="progress-steps-container">
<div class="progress-steps-demo">
<div class="progress-steps" id="progressSteps">
<div class="step active" data-step="1">
<div class="step-icon">1</div>
<div class="step-label">Personal</div>
</div>
<div class="step" data-step="2">
<div class="step-icon">2</div>
<div class="step-label">Billing</div>
</div>
<div class="step" data-step="3">
<div class="step-icon">3</div>
<div class="step-label">Shipping</div>
</div>
<div class="step" data-step="4">
<div class="step-icon">4</div>
<div class="step-label">Confirmation</div>
</div>
</div>
<div class="step-content">
<div class="step-pane active" id="step1">
<h3>Personal Information</h3>
<p>Enter your personal details to get started.</p>
</div>
<div class="step-pane" id="step2">
<h3>Billing Details</h3>
<p>Provide your billing information.</p>
</div>
<div class="step-pane" id="step3">
<h3>Shipping Address</h3>
<p>Enter your shipping address.</p>
</div>
<div class="step-pane" id="step4">
<h3>Confirm Order</h3>
<p>Review and confirm your order.</p>
</div>
</div>
<div class="step-navigation">
<button class="btn btn-secondary" id="prevBtn">Previous</button>
<button class="btn btn-primary" id="nextBtn">Next</button>
</div>
</div>
</div>
.progress-steps-container {
background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
padding: 30px;
border-radius: 20px;
max-width: 600px;
margin: 0 auto;
}
.progress-steps {
display: flex;
justify-content: space-between;
margin-bottom: 40px;
position: relative;
}
.progress-steps::before {
content: '';
position: absolute;
top: 20px;
left: 0;
right: 0;
height: 4px;
background: #e2e8f0;
z-index: 1;
}
.progress-steps .progress-bar {
content: '';
position: absolute;
top: 20px;
left: 0;
height: 4px;
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
z-index: 2;
transition: width 0.3s ease;
width: 0%;
}
.step {
text-align: center;
position: relative;
z-index: 3;
cursor: pointer;
}
.step-icon {
width: 40px;
height: 40px;
background: #e2e8f0;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
color: #999;
margin: 0 auto 10px;
transition: all 0.3s ease;
}
.step.active .step-icon {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
transform: scale(1.1);
}
.step.completed .step-icon {
background: #27ae60;
color: white;
}
.step-label {
font-size: 0.9rem;
color: #999;
font-weight: 500;
transition: all 0.3s ease;
}
.step.active .step-label {
color: #333;
font-weight: 600;
}
.step.completed .step-label {
color: #27ae60;
}
.step-content {
min-height: 150px;
margin-bottom: 30px;
}
.step-pane {
display: none;
animation: fadeIn 0.3s ease;
}
.step-pane.active {
display: block;
}
.step-pane h3 {
margin: 0 0 15px 0;
color: #333;
font-size: 1.5rem;
}
.step-pane p {
color: #666;
line-height: 1.6;
}
.step-navigation {
display: flex;
justify-content: space-between;
}
.btn {
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.btn-secondary {
background: #f1f5f9;
color: #666;
}
.btn-secondary:hover {
background: #e2e8f0;
transform: translateY(-2px);
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
/* Animations */
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Responsive */
@media (max-width: 768px) {
.progress-steps-container {
padding: 20px;
}
.step-label {
font-size: 0.8rem;
}
.step-pane h3 {
font-size: 1.3rem;
}
}
document.addEventListener('DOMContentLoaded', function() {
// Get DOM elements
const steps = document.querySelectorAll('.step');
const stepPanes = document.querySelectorAll('.step-pane');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
const progressBar = document.createElement('div');
// Add progress bar to steps container
progressBar.className = 'progress-bar';
document.querySelector('.progress-steps').appendChild(progressBar);
let currentStep = 1;
const totalSteps = steps.length;
// Initialize progress bar
updateProgressBar();
// Add event listeners to steps
steps.forEach(step => {
step.addEventListener('click', () => {
const stepNumber = parseInt(step.getAttribute('data-step'));
if (stepNumber <= currentStep || step.classList.contains('completed')) {
goToStep(stepNumber);
}
});
});
// Navigation buttons
prevBtn.addEventListener('click', () => {
if (currentStep > 1) {
goToStep(currentStep - 1);
}
});
nextBtn.addEventListener('click', () => {
if (currentStep < totalSteps) {
// Mark current step as completed
steps[currentStep - 1].classList.add('completed');
goToStep(currentStep + 1);
} else {
// Finish process
alert('Process completed!');
}
});
// Go to specific step
function goToStep(stepNumber) {
// Update current step
currentStep = stepNumber;
// Update steps UI
steps.forEach((step, index) => {
step.classList.remove('active');
if (index + 1 < stepNumber) {
step.classList.add('completed');
} else if (index + 1 === stepNumber) {
step.classList.add('active');
}
});
// Update step panes
stepPanes.forEach((pane, index) => {
pane.classList.remove('active');
if (index + 1 === stepNumber) {
pane.classList.add('active');
}
});
// Update progress bar
updateProgressBar();
// Update button states
prevBtn.disabled = currentStep === 1;
nextBtn.textContent = currentStep === totalSteps ? 'Finish' : 'Next';
}
// Update progress bar width
function updateProgressBar() {
const progress = ((currentStep - 1) / (totalSteps - 1)) * 100;
progressBar.style.width = `${progress}%`;
}
});