branalex94 / faq-accordion-card

A frontendmentor.io challenge to create a FAQ accordion card

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Frontend Mentor - FAQ accordion card solution

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

Finished Challenge

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • Mobile-first workflow

What I learned

I learned how to scale images to fit different screens and to implement a few animations on images.

.wrapper {
  flex-direction: row;
  width: 60vw;
  padding-bottom: 0;
  background-image: url(./images/illustration-woman-online-desktop.svg),
    url(./images/bg-pattern-desktop.svg);
  background-repeat: no-repeat, no-repeat;
  background-position: -15% center, -22rem 19%;
  background-size: 50% auto, 100% auto;
}
const toggleQuestion = (e) => {
  const faqContainer = e.currentTarget.children[0];
  const faqTitle = e.currentTarget.children[1];

  faqContainer.style.getPropertyValue("--arrow-direction") === "180deg"
    ? faqContainer.style.setProperty("--arrow-direction", "0")
    : faqContainer.style.setProperty("--arrow-direction", "180deg");
  faqContainer.classList.toggle("faq__question__container__header--active");
  faqTitle.classList.toggle("faq__question__container__text--active");
};

Continued development

I'll be able to use the knowledge I obtained in this project to make better use of the images and DOM manipulation.

Useful resources

Author

About

A frontendmentor.io challenge to create a FAQ accordion card


Languages

Language:CSS 46.0%Language:HTML 45.2%Language:JavaScript 8.8%