Pure HTML and CSS Accordion

Developer
Size
3,485 Kb
Views
24,288

How do I make an pure html and css accordion?

Created and designed (in browser) a pure HTML and CSS expandable accordion for fun. I tried to think outside of the box when designing this (no pun intended).. What is a pure html and css accordion? How do you make a pure html and css accordion? This script and codes were developed by Chris Ota on 15 September 2022, Thursday.

Pure HTML and CSS Accordion Previews

Pure HTML and CSS Accordion - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pure HTML and CSS Accordion</title> <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <ul class="accordion"> <li class="accordion-item"> <input id="s1" class="hide" type="checkbox"> <label for="s1"class="accordion-label">First</label> <ul class="accordion-child"> <li> <label> <input type="checkbox"> Item 1 </label> </li> <li> <label> <input type="checkbox"> Item 2 </label> </li> </ul> </li> <li class="accordion-item"> <input id="s2" class="hide" type="checkbox" checked> <label for="s2" class="accordion-label">Second</label> <p class="accordion-child">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce quis ultrices nunc. Suspendisse a magna purus. In hac habitasse platea dictumst. Nullam sed nisl quis sem dignissim luctus. Etiam luctus mauris nulla, et efficitur massa efficitur ac.</p> </li>
</ul>
</body>
</html>

Pure HTML and CSS Accordion - Script Codes CSS Codes

*, *:before, *:after { box-sizing: border-box;
}
html,
body { height: 100%;
}
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-family: roboto, helvetica, arial, san-serif; color: #666; background: #e0e0e0; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; height: inherit;
}
.hide { clip: rect(0 0 0 0); height: 1px; margin: -1px; padding: 0; position: absolute; width: 1px;
}
.accordion { background: #fff; width: 400px; border: 1px solid #e0e0e0;
}
.accordion-item { position: relative; width: 100%; border-bottom: 1px solid #e0e0e0;
}
.accordion-item:last-child { border-bottom: none;
}
.accordion-label { padding: 20px 0 20px 30px; width: 100%; display: block; font-size: 18px;
}
.accordion-label:hover { cursor: pointer;
}
.accordion-label:before { content: ''; position: absolute; height: 5px; width: 5px; top: 22px; left: 12px; display: inline-block; border-left: 5px solid #999; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
input[type=checkbox]:checked ~ .accordion-label:before { -webkit-transform: rotate(90deg); transform: rotate(90deg);
}
.accordion-child { margin: 0; overflow: hidden; -webkit-transition: all 0.3s ease; transition: all 0.3s ease; opacity: 0; height: 0; -webkit-transform: scale(1, 0); transform: scale(1, 0); -webkit-transform-origin: center top; transform-origin: center top;
}
input[type=checkbox]:checked ~ .accordion-child { border: 1px solid #e0e0e0; margin: 0 -20px 15px -20px; background: #fff; box-shadow: 0 3px 6px 1px rgba(0, 0, 0, 0.16); padding: 30px; height: auto; opacity: 1; -webkit-transform: scale(1, 1); transform: scale(1, 1);
}
Pure HTML and CSS Accordion - Script Codes
Pure HTML and CSS Accordion - Script Codes
Home Page Home
Developer Chris Ota
Username chrisota
Uploaded September 15, 2022
Rating 4.5
Size 3,485 Kb
Views 24,288
Do you need developer help for Pure HTML and CSS Accordion?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Chris Ota (chrisota) Script Codes
Create amazing love letters with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!