Web Code
Login
Sign Up
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Pricing Table Website</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="pricing-table-container"> <div class="pricing-header"> <h2>Please choose a plan below</h2> <div class="plans-switch-container"> <input type="checkbox" class="plans-switch"> <span class="monthly">Monthly</span> <span class="yearly">Yearly</span> </div> </div> <div class="pricing-table"> <div class="table"> <div class="content"> <h3>Basic</h3> <div class="price-container"> <span class="price basic-price">$49</span> <span class="plan-duration">/ month</span> </div> <div class="description"> <p>This plan is the best for individuals who are getting started</p> </div> <ul class="features"> <li>15 Files</li> <li>10 GB Storage</li> <li>Email Support</li> </ul> <a href="#" class="btn">Choose Plan</a> </div> <img src="https://i.postimg.cc/2jV99bKc/Vector-1.png" alt="bg" class="table-bg"> </div> <div class="table best-value"> <span class="value">Best Value</span> <div class="content"> <h3>Professional</h3> <div class="price-container"> <span class="price professional-price">$99</span> <span class="plan-duration">/ month</span> </div> <div class="description"> <p>This plan is for businesses that are getting started</p> </div> <ul class="features"> <li>Unlimited Files</li> <li>25 GB Storage</li> <li>Phone Support</li> </ul> <a href="#" class="btn">Choose Plan</a> </div> <img src="https://i.postimg.cc/zGjkG8QH/Vector-2.png" alt="bg" class="table-bg"> </div> <div class="table"> <div class="content"> <h3>Business</h3> <div class="price-container"> <span class="price business-price">$149</span> <span class="plan-duration">/ month</span> </div> <div class="description"> <p>This plan is the best for large businesses</p> </div> <ul class="features"> <li>Unlimited Files</li> <li>Unlimited Storage</li> <li>Email Support</li> </ul> <a href="#" class="btn">Choose Plan</a> </div> <img src="https://i.postimg.cc/2jV99bKc/Vector-1.png" alt="bg" class="table-bg"> </div> </div> </div> <script src="main.js"></script> </body> </html>
CSS
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); :root{ --dark-blue: #023047; --green: #06d6a0; --yellow: #ffd166; --light-color: #f1faee; --pink: #ef476f; } .pricing-table-container{ font-family: "Poppins", sans-serif; } .pricing-table-container .pricing-header{ display: flex; align-items: center; justify-content: center; } .pricing-table-container h2{ margin-right: 32px; font-size: 24px; } .pricing-table-container .plans-switch{ width: 250px; background: var(--dark-blue); height: 55px; appearance: none; border-radius: 24px; outline: none; cursor: pointer; position: relative; } .pricing-table-container .plans-switch::before{ content: ""; position: absolute; height: 44px; width: 120px; border-radius: 24px; background: var(--green); top: 50%; transform: translateY(-50%); left: 6px; transition: all .5s; } .pricing-table-container .plans-switch:checked::before{ left: 138px; width: 106px; } .pricing-table-container .plans-switch-container{ position: relative; color: #fff; display: inline-block; } .pricing-table-container .plans-switch-container .monthly{ position: absolute; left: 36px; top: 18px; pointer-events: none; } .pricing-table-container .plans-switch-container .yearly{ position: absolute; right: 36px; top: 18px; pointer-events: none; } .pricing-table{ display: flex; align-items: center; justify-content: center; margin-top: 32px; } .pricing-table .table{ background: var(--light-color); width: 260px; padding: 32px; position: relative; } .pricing-table .table .content{ z-index: 200; position: relative; } .pricing-table .table.best-value{ background: var(--dark-blue); color: #fff; border-radius: 24px; width: 280px; } .pricing-table .table.best-value .value{ position: absolute; top: 0; left: 0; right: 0; text-align: center; padding: 8px; border-radius: 24px 24px 0 0; background: var(--pink); font-weight: bold; } .pricing-table .table.best-value .content{ padding-top: 32px; } .pricing-table .table.best-value .price{ font-size: 60px; } .pricing-table .table.best-value a.btn{ background: var(--yellow); color: #000; transition: all .4s; } .pricing-table .table.best-value a.btn:hover{ background: #ffe4a4;} .pricing-table .table.best-value .description{ color: #eee; } .pricing-table .table img.table-bg{ position: absolute; bottom: 0; left: 0; right: 0; width: 100%; } .pricing-table .price-container{ display: flex; align-items: center; } .pricing-table h3{ font-size: 24px; margin-top: 0; margin-bottom: 0; } .pricing-table .price-container .price{ font-size: 56px; font-weight: bold; padding-right: 16px; } .pricing-table .description{ font-size: 15px; text-align: justify; color: #222; } .pricing-table .features{ list-style: none; padding: 0; } .pricing-table .features li{ margin: 24px 0; display: flex; align-items: center; } .pricing-table .features li::before{ content: url('https://i.postimg.cc/R00sKW5z/bi-check-circle-fill.png'); margin-right: 16px; margin-top: 4px; } .pricing-table a.btn{ background: var(--dark-blue); padding: 16px 0; display: inline-block; width: 100%; color: #fff; font-size: 18px; font-weight: bold; text-align: center; text-decoration: none; border-radius: 24px; margin-top: 16px; transition: all .4s; } .pricing-table a.btn:hover{ background: #022435;} @media screen and (max-width: 768px){ .pricing-table{ display: grid; gap: 20px; } .pricing-table .table{ width: 280px; border-radius: 24px; overflow: hidden; } .pricing-table h3{ text-align: center; } .pricing-table .price-container{ justify-content: center; } } @media screen and (max-width: 660px){ .pricing-table-container .pricing-header{ display: flex; flex-wrap: wrap; } .pricing-table-container .pricing-header h2{ text-align: center; } .pricing-table-container .plans-switch-container{ align-items: center; justify-content: center; } }
JS
const plansSwitch = document.querySelector(".plans-switch"); const basicPrice = document.querySelector(".basic-price"); const professionalPrice = document.querySelector(".professional-price"); const businessPrice = document.querySelector(".business-price"); const planDuration = document.querySelectorAll(".plan-duration"); plansSwitch.addEventListener("change", () => { if(plansSwitch.checked){ basicPrice.innerText = "$349"; professionalPrice.innerText = "$499"; businessPrice.innerText = "$799"; planDuration.forEach(p => { p.innerText = "/ year"; }); } else{ basicPrice.innerText = "$49"; professionalPrice.innerText = "$99"; businessPrice.innerText = "$149"; planDuration.forEach(p => { p.innerText = "/ month"; }); } });
Output