Skip to content

Commit

Permalink
completed faq collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
tsr-kairi committed Jul 1, 2021
1 parent 4acbc48 commit 656d66a
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Day 12 - FAQ Collapse/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const toggles = document.querySelectorAll(".faq-toggle");

toggles.forEach((toggle) => {
toggle.addEventListener("click", () => {
toggle.parentNode.classList.toggle("active");
});
});
78 changes: 78 additions & 0 deletions Day 12 - FAQ Collapse/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="./style.css" />
<title>FAQ | Collapse</title>
</head>
<body>
<h1>Frequently Asked Questions</h1>
<div class="faq-container">
<div class="faq active">
<h3 class="faq-title">Why shouldn't we trust atoms?</h3>
<p class="faq-text">They make up everything</p>

<button class="faq-toggle">
<i class="fas fa-chevron-down"></i>
<i class="fas fa-chevron-right"></i>
</button>
</div>

<div class="faq">
<h3 class="faq-title">
What do you call someone with no body and no nose?
</h3>
<p class="faq-text">Nobody Knows</p>

<button class="faq-toggle">
<i class="fas fa-chevron-down"></i>
<i class="fas fa-chevron-right"></i>
</button>
</div>

<div class="faq">
<h3 class="faq-title">
What's the object-oriented why to become wealthy?
</h3>
<p class="faq-text">Inheritance</p>

<button class="faq-toggle">
<i class="fas fa-chevron-down"></i>
<i class="fas fa-chevron-right"></i>
</button>
</div>

<div class="faq">
<h3 class="faq-title">
How many tickles does it take to tickle an octopus?
</h3>
<p class="faq-text">Ten-tickles</p>

<button class="faq-toggle">
<i class="fas fa-chevron-down"></i>
<i class="fas fa-chevron-right"></i>
</button>
</div>

<div class="faq">
<h3 class="faq-title">What is 1 + 1?</h3>
<p class="faq-text">Depends on who you are asking</p>

<button class="faq-toggle">
<i class="fas fa-chevron-down"></i>
<i class="fas fa-chevron-right"></i>
</button>
</div>
</div>
<script src="./app.js"></script>
</body>
</html>
115 changes: 115 additions & 0 deletions Day 12 - FAQ Collapse/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
@import url("https://fonts.googleapis.com/css?family=Muli&display=swap");
*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
font-family: "Muli", sans-serif;
background-color: #f0f0f0;
}

h1 {
margin: 50px 0 30px;
text-align: center;
}

.faq-container {
min-width: 400px;
margin: 0 auto;
}

.faq {
background-color: transparent;
border: 1px solid #9fa4a8;
border-radius: 10px;
margin: 20px 0;
padding: 30px;
position: relative;
overflow: hidden;
transition: 0.3s ease;
}

.faq.active {
background-color: white;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.1);
}

.faq.active::before,
.faq.active::after {
content: "\f075";
font-family: "Font Awesome 5 Free";
color: #2ecc71;
font-size: 6.5rem;
position: absolute;
opacity: 0.2;
top: 20px;
left: 20px;
z-index: 0;
}

.faq.active::before {
color: #3498db;
top: -10px;
left: -30px;
transform: rotateY(180deg);
}

.faq-title {
margin: 0 35px 0 0;
}

.faq-text {
display: none;
margin: 30px 0 0;
}

.faq.active .faq-text {
display: block;
}

.faq-toggle {
background-color: transparent;
border: 0;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
padding: 0;
position: absolute;
top: 30px;
right: 30px;
height: 30px;
width: 30px;
}

.faq-toggle:focus {
outline: 0;
}

.faq-toggle .fa-chevron-down {
display: none;
}

.faq.active .faq-toggle .fa-chevron-down {
display: block;
}

.faq-toggle:hover {
border: 1px solid rgb(192, 192, 192);
height: 30px;
width: 30px;
border-radius: 50%;
background-color: rgb(192, 192, 192);
}

.faq-toggle:active {
transform: scale(1.1);
}

.faq.active .faq-toggle .fa-chevron-right {
display: none;
}

0 comments on commit 656d66a

Please sign in to comment.