Responsive Pricing Table HTML & CSS Snippets

Responsive Pricing Table HTML & CSS Snippets

by Frontendor UI Library

HTML

<body>
  <div class="container">
    <div class="top">
      <h1>Plans & Pricing</h1>
      <div class="toggle-btn">
        <span style="margin: 0.8em;">Annually</span>
        <label class="switch">
          <input type="checkbox" id="checbox" onclick="check()" ; />
          <span class="slider round"></span>
        </label>
        <span style="margin: 0.8em;">Monthly</span></div>
    </div>

    <div class="package-container">
      <div class="packages">
        <h1>Basic</h1>
        <h2 class="text1">&dollar;9.99</h2>
        <h2 class="text2">&dollar;119.99</h2>
        <ul class="list">
          <li class="first">2000 Subscribers</li>
          <li>12,000 Emails/month</li>
          <li>Multi-User Accounts</li>
          <li>Email Support</li>
        </ul>
        <a href="#" class="button button1">Start Now</a>
      </div>
      <div class="packages">
        <h1>Professional</h1>
        <h2 class="text1">&dollar;19.99</h2>
        <h2 class="text2">&dollar;239.99</h2>
        <ul class="list">
          <li class="first">Basic +</li>
          <li>Landing Pages</li>
          <li>Pop-up Forms</li>
          <li>Premium Support</li>
        </ul>
        <a href="#" class="button button2">Start Now</a>
      </div>
      <div class="packages">
        <h1>Master</h1>
        <h2 class="text1">&dollar;29.99</h2>
        <h2 class="text2">&dollar;359.99</h2>
        <ul class="list">
          <li class="first">Professional +</li>
          <li>Marketing Automation</li>
          <li>Instagram Ads</li>
          <li>Facebook Ads</li>
        </ul>
        <a href="#" class="button button3">Start Now</a>
      </div>
    </div>
  </div>

  <script src="./script.js"></script>
</body>

CSS

@import url("https://fonts.googleapis.com/css2?family=Play:wght@400;700&display=swap");

body {
  background-color: #f4f4f4;

  font-family: "Play", sans-serif;
}

.container {
  width: 100%;
}

.packages {
  margin: 20px;
  width: 300px;
  padding-bottom: 1.5em;
  height: 100%;
  background-color: #1e2321;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-radius: 20px;
  box-shadow: 0 19px 38px rgba(30, 35, 33, 1), 0 15px 12px rgba(30, 35, 33, 0.2);
  flex-wrap: wrap;
  color: #f4f4f4;
}

h1,
h2 {
  font-size: 2.2em;
}

.list li {
  font-size: 20px;
  list-style: none;
  border-bottom: 1px solid #f4f4f4;
  padding-inline-start: 0;
  border-width: 1px;
  padding: 10px;
}

.first {
  margin-top: 40px;
  border-top: 1px solid #f4f4f4;
}

.list {
  width: 80%;
}

ol,
ul {
  padding: 0;
}

.top {
  display: flex;
  flex-direction: column;
  align-items: center;
}

input,
label {
  display: inline-block;
  vertical-align: middle;
  margin: 10px 0;
}

.button {
  padding: 10px 30px;
  text-decoration: none;
  font-size: 1.4em;
  margin: 15px 15px;
  border-radius: 50px;
  color: #f4f4f4;
  transition: all 0.3s ease 0s;
}

.button:hover {
  transform: scale(1.2);
}

.button1 {
  background-color: #00cc99;
  box-shadow: 0 0 10px 0 #00cc99 inset, 0 0 20px 2px #00cc99;
}

.button2 {
  background-color: #ff007c;
  box-shadow: 0 0 10px 0 #ff007c inset, 0 0 20px 2px #ff007c;
}

.button3 {
  background-color: #ffae42;
  box-shadow: 0 0 10px 0 #ffae42 inset, 0 0 20px 2px #ffae42;
}

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #1e2321;
  -webkit-transition: 0.4s;

  box-shadow: 2px 6px 25px #1e2321;
  transform: translate(0px, 0px);
  transition: 0.6s ease transform, 0.6s box-shadow;
}

.slider:before {
  position:...

JavaScript

function check() {
  var checkBox = document.getElementById("checbox");
  var text1 = document.getElementsByClassName("text1");
  var text2 = document.getElementsByClassName("text2");

  for (var i = 0; i < text1.length; i++) {
    if (checkBox.checked == true) {
      text1[i].style.display = "block";
      text2[i].style.display = "none";
    } else if (checkBox.checked == false) {
      text1[i].style.display = "none";
      text2[i].style.display = "block";
    }
  }
}
check();