Angular Accordion: A Viral Coder’s Guide to HTML and CSS 🔥♥️

Posted by

Accordion in Angular

.accordion {
background-color: #f9f9f9;
color: #333;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
}

.accordion.active, .accordion:hover {
background-color: #ddd;
}

.panel {
padding: 0 18px;
display: none;
background-color: white;
overflow: hidden;
}

Accordion Example

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore fugiat nulla pariatur.

var acc = document.getElementsByClassName(“accordion”);
var i;

for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.display === "block") {
panel.style.display = "none";
} else {
panel.style.display = "block";
}
});
}

0 0 votes
Article Rating
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@viral_coder
9 months ago
@Sumitkumar-yz4pl
9 months ago

💯💯