HTML CSS FAQ Design | Webdevtrick.com

Содержание
  1. Create a FAQ Section using HTML ,CSS & JavaScript
  2. HTML Code for FAQ Section
  3. Frequently Asked Questions
  4. CSS Code for FAQ Section
  5. JavaScript Code for FAQ Section
  6. Final Output Of FAQ Section using HTML ,CSS & JavaScript
  7. How to Build an FAQ Page With HTML and Javascript
  8. What is an FAQ Page?
  9. Why do you need an FAQ page?
  10. Prerequisites
  11. FAQ'S What is an FAQ Page? Lorem ipsum dolor, sit amet consectetur adipisicing elit. Velit saepe sequi, illum facere necessitatibus cum aliquam id illo omnis maxime, totam soluta voluptate amet ut sit ipsum aperiam. Perspiciatis, porro! Why do you need an FAQ page? Lorem ipsum dolor, sit amet consectetur adipisicing elit. Velit saepe sequi, illum facere necessitatibus cum aliquam id illo omnis maxime, totam soluta voluptate amet ut sit ipsum aperiam. Perspiciatis, porro! Does it improves the user experience of a website? Lorem ipsum dolor, sit amet consectetur adipisicing elit. Velit saepe sequi, illum facere necessitatibus cum aliquam id illo omnis maxime, totam soluta voluptate amet ut sit ipsum aperiam. Perspiciatis, porro!
  12. What is an FAQ Page? Lorem ipsum dolor, sit amet consectetur adipisicing elit. Velit saepe sequi, illum facere necessitatibus cum aliquam id illo omnis maxime, totam soluta voluptate amet ut sit ipsum aperiam. Perspiciatis, porro!
  13. Why do you need an FAQ page? Lorem ipsum dolor, sit amet consectetur adipisicing elit. Velit saepe sequi, illum facere necessitatibus cum aliquam id illo omnis maxime, totam soluta voluptate amet ut sit ipsum aperiam. Perspiciatis, porro!
  14. Does it improves the user experience of a website? Lorem ipsum dolor, sit amet consectetur adipisicing elit. Velit saepe sequi, illum facere necessitatibus cum aliquam id illo omnis maxime, totam soluta voluptate amet ut sit ipsum aperiam. Perspiciatis, porro!
  15. Conclusion
  16. Как добавить на сайт раздел FAQ с раскрывающимися ответами
  17. Структура HTML
  18. Стилизация с помощью CSS
  19. Добавление интерактивности с помощью JavaScript
Читайте также:  Java reflect create class

Create a FAQ Section using HTML ,CSS & JavaScript

You see when we type or search something on our search engine earlier it used to give the result and a link that has all the content related to it so that the user doesn’t need to scroll or surf more time to find the one problem solution.

Nowadays as technology and AI updates there’s a feature has came known as FAQ this basically gives all the answers what questions will be in the head of the user if he wants to download a game, FAQ will be generated with pros and cons as well as the alternative sites or tips, etc. FAQ feature is basically introduced to solve the 75% – 80% problem of the user.

Now as a developer there’s nothing we can’t recreate or code so let’s see the building of this feature. In This Article We Create FAQ Section using HTML ,CSS & JavaScript.On that note, I welcome you all to Codewithrandom with a new blog in which we’ll see the creation FAQ feature.

I hope you have got an idea for this project.

HTML Code for FAQ Section

      

Frequently Asked Questions

What can JavaScript Do?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Elementum sagittis vitae et leo duis ut. Ut tortor pretium viverra suspendisse potenti.

How JavaScript Can Modify HTML and CSS Values?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Elementum sagittis vitae et leo duis ut. Ut tortor pretium viverra suspendisse potenti.

What Is SVG?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Elementum sagittis vitae et leo duis ut. Ut tortor pretium viverra suspendisse potenti.

Is FAQ Section Matters In Website?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Elementum sagittis vitae et leo duis ut. Ut tortor pretium viverra suspendisse potenti.

How To Create a Light FAQ Element?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Elementum sagittis vitae et leo duis ut. Ut tortor pretium viverra suspendisse potenti.

In this HTML Code we have defined the structure in which under the accordion item tag we have defined some question and their answers and then we have linked a jQuery code and in the script tag because it will be going to use when we will code the JavaScript now lets code the CSS part to add styling to the FAQ Design.

master frontend development ebook cover

Do you want to learn HTML to JavaScript? 🔥

If yes, then here is our Master Frontend: Zero to Hero eBook! 📚 In this eBook, you’ll learn complete HTML, CSS, Bootstrap, and JavaScript from beginner to advance level. 💪 It includes 450 Projects with source code.

CSS Code for FAQ Section

@import url(‘https://fonts.googleapis.com/css?family=Hind:300,400’); *, *:before, *:after < -webkit-box-sizing: inherit; box-sizing: inherit; >html < -webkit-box-sizing: border-box; box-sizing: border-box; >body < margin: 0; padding: 0; font-family: 'Hind', sans-serif; background: #fff; color: #4d5974; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; min-height: 100vh; >.container < margin: 0 auto; padding: 4rem; width: 48rem; >h3 < font-size: 1.75rem; color: #373d51; padding: 1.3rem; margin: 0; >.accordion a < position: relative; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; width: 100%; padding: 1rem 3rem 1rem 1rem; color: #7288a2; font-size: 1.15rem; font-weight: 400; border-bottom: 1px solid #e5e5e5; >.accordion a:hover, .accordion a:hover::after < cursor: pointer; color: #ff5353; >.accordion a:hover::after < border: 1px solid #ff5353; >.accordion a.active < color: #ff5353; border-bottom: 1px solid #ff5353; >.accordion a::after < font-family: 'Ionicons'; content: '\f218'; position: absolute; float: right; right: 1rem; font-size: 1rem; color: #7288a2; padding: 5px; width: 30px; height: 30px; -webkit-border-radius: 50%; -moz-border-radius: 50%; border-radius: 50%; border: 1px solid #7288a2; text-align: center; >.accordion a.active::after < font-family: 'Ionicons'; content: '\f209'; color: #ff5353; border: 1px solid #ff5353; >.accordion .content < opacity: 0; padding: 0 1rem; max-height: 0; border-bottom: 1px solid #e5e5e5; overflow: hidden; clear: both; -webkit-transition: all 0.2s ease 0.15s; -o-transition: all 0.2s ease 0.15s; transition: all 0.2s ease 0.15s; >.accordion .content p < font-size: 1rem; font-weight: 300; >.accordion .content.active

In this code of CSS we have styled the FAQ design in which we have styled the accordion tag to make it look like a FAQ design which is loaded after the user searches in the google we have defined the transition, opacity, padding, margin, font-family, font-weight etc. So that every thing is aligned properly and it doesn’t get messy while we run it. Now lets code the JavaScript part to make it responsive.

JavaScript Code for FAQ Section

const items = document.querySelectorAll(".accordion a"); function toggleAccordion() < this.classList.toggle('active'); this.nextElementSibling.classList.toggle('active'); >items.forEach(item => item.addEventListener('click', toggleAccordion));

In this JS code we have first used the syntax called document.querySelector in it will toggle the Question and embed the answer in it. And as soon as the user will click on the dropdown it will appear. To make the click responsive we have added a syntax addEventListener which will make it responsive as soon as the user will click it. Let us see the final output of the FAQ Design.

Final Output Of FAQ Section using HTML ,CSS & JavaScript

We have Successfully created our FAQ Section using HTML ,CSS & JavaScript. You can use this project for your personal needs and the respective lines of code are given with the code pen link mentioned above.

If you find out this Blog helpful, then make sure to search code with random on google for Front End Projects with Source codes and make sure to Follow the Code with Random Instagram page.

Источник

How to Build an FAQ Page With HTML and Javascript

The Frequently Asked Questions (FAQ) page can improve user experience. All websites should have an FAQ page because it reduces the time your employees need to answer simple questions. It allows visitors to find answers to all their questions in one place. And an FAQ page can be a great source of content ideas.

In this tutorial, I’m going to show you how to create a simple FAQ page in HTML, CSS, and JavaScript. Before we start building our FAQ page, we will look out what an FAQ page is and why it is important.

What is an FAQ Page?

The Frequently Asked Questions page is one of the most helpful pages on any website. It allows visitors to find answers to all their questions in one place. They give your visitors the chance to learn more about your website with answers to common concerns or questions anyone might have.

FAQ is one of the most overlooked pages, but you can hardly find a popular online store or a website without it.

Why do you need an FAQ page?

  1. Improves the user experience of a website.
  2. Reduces the time your employees need to answer simple questions.
  3. Allows visitors to find answers to all their questions in one place.
  4. It is a great source for content ideas.

Prerequisites

This tutorial assumes you are comfortable using HTML, CSS and Javascript. Before we begin you will have to create the following files: HTML file, CSS file , and the last JavaScript file.

The segment below describes the steps to be taken for building this FAQ page.

Step One: Structuring our HTML documents

HTML Code: in this section, the elements of the FAQ page are created and loaded. Next, we create and link the style.css and index.js file. add font links and icon links. It also defines the structure of the FAQ page.

We wrapped our HTML elements in a section with a class name of FAQ-container. This section contains different elements which are split into parts. The first part contains the question while the second part contains the answers that belong to the same category section.

         

FAQ'S

What is an FAQ Page?

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Velit saepe sequi, illum facere necessitatibus cum aliquam id illo omnis maxime, totam soluta voluptate amet ut sit ipsum aperiam. Perspiciatis, porro!


Why do you need an FAQ page?

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Velit saepe sequi, illum facere necessitatibus cum aliquam id illo omnis maxime, totam soluta voluptate amet ut sit ipsum aperiam. Perspiciatis, porro!


Does it improves the user experience of a website?

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Velit saepe sequi, illum facere necessitatibus cum aliquam id illo omnis maxime, totam soluta voluptate amet ut sit ipsum aperiam. Perspiciatis, porro!

Step Two: Positioning our layouts and styling

CSS Code: This section contains the positioning of our FAQ page, the font size, and the styling of the elements.

  1. Create layout columns,
  2. For our content to be readable, we must use a good font. Check out this link for the font used in the project google font.
  3. Center page in the middle of the window
body < font-family: 'Work Sans', sans-serif; >.faq-heading < border-bottom: #777; padding: 20px 60px; >.faq-container < display: flex; justify-content: center; flex-direction: column; >.hr-line < width: 60%; margin: auto; >/* Style the buttons that are used to open and close the faq-page body */ .faq-page < /* background-color: #eee; */ color: #444; cursor: pointer; padding: 30px 20px; width: 60%; border: none; outline: none; transition: 0.4s; margin: auto; >.faq-body < margin: auto; /* text-align: center; */ width: 50%; padding: auto; >/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */ .active, .faq-page:hover < background-color: #F9F9F9; >/* Style the faq-page panel. Note: hidden by default */ .faq-body < padding: 0 18px; background-color: white; display: none; overflow: hidden; >.faq-page:after < content: '\02795'; /* Unicode character for "plus" sign (+) */ font-size: 13px; color: #777; float: right; margin-left: 5px; >.active:after < content: "\2796"; /* Unicode character for "minus" sign (-) */ >

Step Three: Adding functionalities

JavaScript Code : This section contains the part of the code that controls the functionalities of the FAQ page: the event handling.

Now we are going to add javascript to make our FAQ page functional. Currently, our page looks beautiful but doesn’t work well because we haven’t included our javascript, but we can make it so much better.

main.js file var faq = document.getElementsByClassName("faq-page"); var i; for (i = 0; i < faq.length; i++) < faq[i].addEventListener("click", function () < /* Toggle between adding and removing the "active" class, to highlight the button that controls the panel */ this.classList.toggle("active"); /* Toggle between hiding and showing the active panel */ var body = this.nextElementSibling; if (body.style.display === "block") < body.style.display = "none"; >else < body.style.display = "block"; >>); >

Conclusion

Having an FAQ page is essential and can serve as a better experience for your end-users that brings real value to your website. I hope this article has given you reasons for having an FAQ page on your website and how to build it.

You can check out the code here on my Github page

I am a software developer with development experience in frontend building responsive website sites using these web technologies like Javascript, VueJs, HTML and CSS, Bootstrap Tailwind CSS. I specialize in converting designs to Code, and I love teaching and sharing my technical ideas through an article.

Источник

Как добавить на сайт раздел FAQ с раскрывающимися ответами

Узнайте, как легко создать привлекательный и функциональный раздел FAQ с раскрывающимися ответами с помощью HTML, CSS и JavaScript!

Person browsing a FAQ section on a website

Создание раздела FAQ (Frequently Asked Questions) с раскрывающимися ответами является отличным способом предоставления информации посетителям вашего сайта. В этой статье мы рассмотрим, как создать такой раздел с использованием HTML, CSS и JavaScript.

Структура HTML

Для начала создадим структуру нашего раздела FAQ с помощью HTML. В этом примере мы будем использовать теги и , которые предоставляют нативную поддержку раскрывающихся элементов в HTML5.

  
Вопрос 1: Какая-то информация?

Ответ на вопрос 1: Это информация о чем-то важном.

Вопрос 2: Какая-то другая информация?

Ответ на вопрос 2: Это информация о чем-то другом важном.

Стилизация с помощью CSS

Теперь добавим стили к нашему разделу FAQ с помощью CSS, чтобы сделать его более привлекательным визуально. В следующем примере мы зададим стили для элементов и :

.faq < width: 80%; margin: 0 auto; >details < background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px; padding: 0.5em; margin-bottom: 1em; >summary < font-weight: bold; cursor: pointer; >details[open]

😉 Обратите внимание, что вы можете настроить эти стили по своему усмотрению или в соответствии с дизайном вашего сайта.

Добавление интерактивности с помощью JavaScript

Наконец, добавим немного JavaScript для того, чтобы при открытии одного вопроса другие автоматически закрывались, создавая аккордеонный эффект:

document.querySelectorAll('.faq details').forEach((item) => < item.addEventListener('toggle', (event) => < if (event.target.open) < document.querySelectorAll('.faq details').forEach((otherItem) => < if (otherItem !== event.target) < otherItem.removeAttribute('open'); >>); > >); >);

Теперь у вас есть функциональный раздел FAQ с раскрывающимися ответами! 🎉

Если вы хотите продолжить изучение веб-разработки и узнать больше о создании сайтов, рекомендую посетить

Источник

Оцените статью