<div class="pricing-container">
<div class="switcher-wrapper">
<span class="monthly active">Mensual</span>
<label class="switch">
<input type="checkbox" id="plan-switcher">
<span class="slider round"></span>
</label>
<span class="yearly">Anual</span>
</div>
<div class="pricing-plans">
<div class="plan">
<h3>Básico</h3>
<div class="price-container">
<span class="price" data-monthly="$10" data-yearly="$100">$10</span>
<span class="period">/mes</span>
</div>
<ul>
<li><span class="check">✔</span>Característica 1</li>
<li><span class="check">✔</span>Característica 2</li>
<li><span class="check">✔</span>Característica 3</li>
</ul>
<button class="choose-plan">Elegir Plan</button>
</div>
<div class="plan featured">
<div class="featured-badge">Más Popular</div>
<h3>Pro</h3>
<div class="price-container">
<span class="price" data-monthly="$20" data-yearly="$200">$20</span>
<span class="period">/mes</span>
</div>
<ul>
<li><span class="check">✔</span>Característica 1</li>
<li><span class="check">✔</span>Característica 2</li>
<li><span class="check">✔</span>Característica 3</li>
</ul>
<button class="choose-plan">Elegir Plan</button>
</div>
<div class="plan">
<h3>Empresa</h3>
<div class="price-container">
<span class="price" data-monthly="$30" data-yearly="$300">$30</span>
<span class="period">/mes</span>
</div>
<ul>
<li><span class="check">✔</span>Característica 1</li>
<li><span class="check">✔</span>Característica 2</li>
<li><span class="check">✔</span>Característica 3</li>
</ul>
<button class="choose-plan">Elegir Plan</button>
</div>
</div>
</div>
.pricing-container {
font-family: 'Inter', sans-serif;
text-align: center;
padding: 40px 20px;
background-color: #f7f9fc;
}
.switcher-wrapper {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 40px;
font-size: 16px;
color: #6b7280;
}
.switcher-wrapper .monthly, .switcher-wrapper .yearly {
cursor: pointer;
padding: 5px 10px;
transition: color 0.3s;
}
.switcher-wrapper .active {
color: #1d4ed8;
font-weight: 600;
}
.switch {
position: relative;
display: inline-block;
width: 50px;
height: 28px;
margin: 0 15px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
border-radius: 28px;
}
.slider:before {
position: absolute;
content: "";
height: 20px;
width: 20px;
left: 4px;
bottom: 4px;
background-color: white;
transition: .4s;
border-radius: 50%;
}
input:checked + .slider {
background-color: #2563eb;
}
input:checked + .slider:before {
transform: translateX(22px);
}
.pricing-plans {
display: flex;
justify-content: center;
gap: 30px;
flex-wrap: wrap;
}
.plan {
background-color: #ffffff;
border: 1px solid #e5e7eb;
border-radius: 12px;
padding: 30px;
width: 300px;
text-align: left;
transition: transform 0.3s, box-shadow 0.3s;
position: relative;
}
.plan:hover {
transform: translateY(-10px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.plan.featured {
border: 2px solid #2563eb;
background: linear-gradient(135deg, #3b82f6, #1d4ed8);
color: white;
}
.featured-badge {
position: absolute;
top: -15px;
left: 50%;
transform: translateX(-50%);
background-color: #ef4444;
color: white;
padding: 5px 15px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
}
.plan h3 {
font-size: 24px;
font-weight: 600;
margin-bottom: 20px;
}
.price-container {
display: flex;
align-items: baseline;
margin-bottom: 20px;
}
.price {
font-size: 48px;
font-weight: 700;
}
.period {
font-size: 16px;
color: #6b7280;
margin-left: 5px;
}
.plan.featured .period {
color: #d1d5db;
}
.plan ul {
list-style: none;
padding: 0;
margin-bottom: 30px;
}
.plan ul li {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.check {
color: #10b981;
margin-right: 10px;
font-size: 20px;
}
.plan.featured .check {
color: #a7f3d0;
}
.choose-plan {
width: 100%;
padding: 15px;
border: none;
border-radius: 8px;
background-color: #2563eb;
color: white;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: background-color 0.3s;
}
.plan.featured .choose-plan {
background-color: white;
color: #1d4ed8;
}
.choose-plan:hover {
background-color: #1d4ed8;
}
.plan.featured .choose-plan:hover {
background-color: #e0e7ff;
}
document.addEventListener('DOMContentLoaded', () => {
const switcher = document.getElementById('plan-switcher');
const prices = document.querySelectorAll('.price');
const periods = document.querySelectorAll('.period');
const monthlyEl = document.querySelector('.monthly');
const yearlyEl = document.querySelector('.yearly');
function updatePlans(isYearly) {
prices.forEach(price => {
price.textContent = isYearly ? price.dataset.yearly : price.dataset.monthly;
});
periods.forEach(period => {
period.textContent = isYearly ? '/año' : '/mes';
});
if (isYearly) {
yearlyEl.classList.add('active');
monthlyEl.classList.remove('active');
} else {
monthlyEl.classList.add('active');
yearlyEl.classList.remove('active');
}
}
switcher.addEventListener('change', () => {
updatePlans(switcher.checked);
});
monthlyEl.addEventListener('click', () => {
switcher.checked = false;
updatePlans(false);
});
yearlyEl.addEventListener('click', () => {
switcher.checked = true;
updatePlans(true);
});
});