BM Balmiki Mandal 25 May 2023 0 views 0 comments MERN Full Stack

Create a Unique 3D Package Toggle Effect with Pure CSS

How to Make a Pure CSS 3D Package Toggle in HTML

Creating a package toggle button with just HTML and CSS is an easy way to add a simple “toggle” feature to your webpage. This tutorial will walk you through the steps of creating a pure CSS 3D package toggle button.

Step 1: Add an HTML Container

The first step is to add an HTML container. This can be done by simply adding the following line to your HTML document:

<div class='container'></div>

Step 2: Add CSS for Styling the Container

Next, add some basic styling for the container. This includes adding background color, borders, and basic sizing. For example, the following code will create a container with a white background, a grey border, and a 500px width:

.container {
  width: 500px;
  background-color: #FFFFFF;
  border: 2px solid #999999;
}

Step 3: Add HTML for the Toggle Elements

Next, add the HTML for the toggle elements. This includes the toggle button, the label, and the content that will be visible when the toggle is activated. The following code will create a toggle button, a label, and a div that contains the content:

<div class='container'>
  <div class='toggle-button'>Toggle</div>
  <label>Package Contents</label>
  <div class='content'>
    <ul>
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
    </ul>
  </div>
</div>

Step 4: Add CSS for Displaying the Content

Now it's time to add some CSS that will display the content when the toggle is activated. This can be done by adding the following code:

.content {
  display: none;
}

.toggle-button:checked + .content {
  display: block;
}

Step 5: Add CSS for Creating the 3D Effect

Finally, add some CSS that will create the 3D effect for the toggle button. This can be done by adding the following code:

.toggle-button {
  border-radius: 50%;
  padding: 4px;
  width: 30px;
  height: 30px;
  background-color: #f3f3f3;
  position: relative;
  box-shadow: -1px -1px 1px #999;
  transition: all 0.2s ease;
}

.toggle-button:before {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  width: 40px;
  height: 40px;
  background-color: #fff;
  border-radius: 50%;
  box-shadow: -1px -1px 1px #999;
  transition: all 0.2s ease;
}

.toggle-button:after {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  width: 20px;
  height: 20px;
  background-color: #999;
  border-radius: 50%;
  box-shadow: -1px -1px 1px #999;
  transition: all 0.2s ease;
}

.toggle-button:checked:before {
  top: 5px;
  left: 5px;
  box-shadow: 1px 1px 1px #999;
}

.toggle-button:checked:after {
  top: -5px;
  left: -5px;
  box-shadow: 1px 1px 1px #999;
}

Conclusion

By following these steps, you can easily create a pure CSS 3D package toggle button with HTML and CSS. As you can see, creating this toggle button requires very minimal code and can be a great way to add a simple toggle feature to your website.

0 Comments

No comments yet, Be the first to comment.

Post a Comment

Please sign in to post a comment.

Related Posts

Enhance Your Website's User Experience with Ajax Comment System for Laravel

 Ajax Comment System for Laravel If you're looking for a reliable and efficient way to manage comments on you...

BM Balmiki Mandal 26 May 2023
10 Best CSS Animation Courses to Take in 2023

10 Best CSS Animation Courses to Take in 2023 CSS is a powerful tool for web developers and animators alike....

BM Balmiki Mandal 26 May 2023
14 Best Free CSS Layout Courses to Take in 2023

14 Best Free CSS Layout Courses to Take in 2023 Introduction CSS is a vital part of website and web applicat...

BM Balmiki Mandal 26 May 2023