This is a solution to the FAQ accordion card challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- View the optimal layout for the component depending on their device's screen size
- See hover states for all interactive elements on the page
- Hide/Show the answer to a question when the question is clicked
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Mobile-first workflow
- Styled Components - For styles
I learned more about the use of the grid and flexbox. I also learned how to use the toggle function in javascript. I also learned how to use the :before and :after pseudo elements. I also learned how to use the transform property in css.
<h1>Some HTML code I'm proud of</h1>
.active .arrow-icon {
transform: rotate(180deg);
}
for (i = 0; i < acc.length; i++) {
// Loop through all accordion buttons and add event listeners to them
acc[i].addEventListener("click", function () {
// When the user clicks on an accordion button, toggle between hiding and showing the active panel
// Close the current active panel
if (currentPanel && currentPanel != this.nextElementSibling) {
currentPanel.style.maxHeight = null;
currentPanel.previousElementSibling.classList.remove("active");
}
I also want to learn more about the use of the transform property in css. I also want to learn more about the use of the :before and :after pseudo elements. I also want to learn more about the use of the toggle function in javascript.
- W3schools - This helped me for the use of the transform property in css. I really liked this pattern and will use it going forward.
- W3schools - This helped me for the use of the :before and :after pseudo elements.
- W3schools - This helped me for the use of the toggle function in javascript.
- Website - Elisabeth Erkekoglou
- Frontend Mentor - @elic4vet
- Instagram - @elisa.codes23