Skip to content

elic4vet/faq-card

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - FAQ accordion card

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.

Table of contents

Overview

The challenge

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

Screenshot

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • CSS Grid
  • Mobile-first workflow
  • Styled Components - For styles

What I learned

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");
    }

Continued development

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.

Useful resources

  • 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.

Author