Html css code for frequently asked questions

Features of this Modern FAQ Section: 

 Clean, Modern Design: 
  •  Card-based layout with subtle shadows 
  •  Smooth color transitions and animations 
  •  Fully responsive for all devices
 
<div class="faq-container"> <h1 class="faq-title">Frequently Asked Questions</h1> <div class="faq-item"> <div class="faq-question"><span>What is your service about?</span></div> <div class="faq-answer"> <p>Our service provides innovative solutions to help you achieve your goals with cutting-edge technology.</p> </div> </div> <div class="faq-item"> <div class="faq-question"><span>How can I get started?</span></div> <div class="faq-answer"> <p>Simply sign up on our website, choose a plan, and follow the onboarding guide to get started.</p> </div> </div> <div class="faq-item"> <div class="faq-question"><span>What are the pricing options?</span></div> <div class="faq-answer"> <p>We offer flexible pricing plans tailored to your needs. Visit our pricing page for more details.</p> </div> </div> <div class="faq-item"> <div class="faq-question"><span>Is there customer support?</span></div> <div class="faq-answer"> <p>Yes, we provide 24/7 customer support via chat, email, and phone to assist you.</p> </div> </div> </div>
CSS provides style to an HTML page. To make the page attractive create a CSS file with the name style.css and remember that you have to make a file with a .css extension.


        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background: #1a1a1a;
            color: #ffffff;
            line-height: 1.6;
            padding: 20px;
        }

        .faq-container {
            max-width: 800px;
            margin: 0 auto;
            padding: 40px 20px;
        }

        .faq-title {
            text-align: center;
            font-size: 2.5em;
            margin-bottom: 40px;
            background: linear-gradient(45deg, #ff0000, #ff6600);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }

        .faq-item {
            margin-bottom: 20px;
            border-radius: 10px;
            overflow: hidden;
            background: #2a2a2a;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
            transition: transform 0.3s ease;
        }

        .faq-item:hover {
            transform: translateY(-5px);
        }

        .faq-question {
            padding: 20px;
            font-size: 1.2em;
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: linear-gradient(45deg, #ff0000, #ff6600);
        }

        .faq-question span {
            color: #ffffff;
            font-weight: bold;
        }

        .faq-answer {
            max-height: 0;
            overflow: hidden;
            padding: 0 20px;
            background: #2a2a2a;
            transition: max-height 0.3s ease, padding 0.3s ease;
        }

        .faq-answer p {
            padding: 20px 0;
            color: #cccccc;
        }

        .faq-item.active .faq-answer {
            max-height: 200px;
            padding: 0 20px;
        }

        .faq-question::after {
            content: '\25BC';
            color: #ffffff;
            transition: transform 0.3s ease;
        }

        .faq-item.active .faq-question::after {
            transform: rotate(180deg);
        }

        @media (max-width: 600px) {
            .faq-title {
                font-size: 2em;
            }

            .faq-question {
                font-size: 1em;
            }
        }
JavaScript makes the page work functionally. At last, create a JavaScript file with the name of script.js, and remember that you've got to make a file with a .js extension.


 document.querySelectorAll('.faq-question').forEach(item => {
            item.addEventListener('click', () => {
                const faqItem = item.parentElement;
                const isActive = faqItem.classList.contains('active');

                document.querySelectorAll('.faq-item').forEach(i => {
                    i.classList.remove('active');
                    i.querySelector('.faq-answer').style.maxHeight = '0';
                });

                if (!isActive) {
                    faqItem.classList.add('active');
                    const answer = faqItem.querySelector('.faq-answer');
                    answer.style.maxHeight = answer.scrollHeight + 'px';
                }
            });
        });

Thank you
Learning robo team

Post a Comment

Thank you
Learning robo team

Post a Comment (0)

Previous Post Next Post
Learning Robo says...
code copied
Welcome