Nice!
COPY
* {
margin: 0;
padding: 0;
list-style: none;
box-sizing: border-box;
}
.accordion {
padding: clamp(40px, 6vw, 80px) 15px;
background: #f5faff;
font-family: "Noto Serif JP", serif;
}
.accordion ul {
max-width: 900px;
margin: 0 auto;
list-style: none;
}
.accordion ul li {
padding: 20px 5px;
border-bottom: solid 1px #dce3eb;
}
.accordion ul li:first-child {
border-top: solid 1px #dce3eb;
}
.accordion ul li .Q {
padding-right: 1.5em;
font-size: 16px;
font-weight: 500;
line-height: 1.8;
color: #203953;
position: relative;
cursor: pointer;
}
.accordion ul li .Q:after {
content: "";
display: block;
width: 0.5em;
height: 0.5em;
border-right: solid 2px #547596;
border-bottom: solid 2px #547596;
position: absolute;
top: 35%;
right: 0;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transition: 0.3s;
transition: 0.3s;
}
.accordion ul li .Q.open:after {
top: 40%;
-webkit-transform: rotate(-135deg);
transform: rotate(-135deg);
}
.accordion ul li .A {
max-height: 0;
overflow: hidden;
font-size: 15px;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.accordion ul li .A.open .txt {
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
}
.accordion ul li .A .txt {
padding-top: 15px;
opacity: 0;
-webkit-transition: 0.5s 0.2s;
transition: 0.5s 0.2s;
-webkit-transform: translateY(5px);
transform: translateY(5px);
}
.accordion ul li .A .txt p {
margin-bottom: 1em;
}
.accordion ul li .A .txt p:last-child {
margin-bottom: 0;
}
/*# sourceMappingURL=style.css.map */
Nice!
COPY
* {
margin: 0;
padding: 0;
list-style: none;
box-sizing: border-box;
}
.accordion {
padding: clamp(40px, 6vw, 80px) 15px;
background: #f5faff;
font-family: "Noto Serif JP", serif;
ul {
max-width: 900px;
margin: 0 auto;
list-style: none;
li {
padding: 20px 5px;
border-bottom: solid 1px #dce3eb;
&:first-child {
border-top: solid 1px #dce3eb;
}
.Q {
padding-right: 1.5em;
font-size: 16px;
font-weight: 500;
line-height: 1.8;
color: #203953;
position: relative;
cursor: pointer;
&:after {
content: "";
display: block;
width: 0.5em;
height: 0.5em;
border-right: solid 2px #547596;
border-bottom: solid 2px #547596;
position: absolute;
top: 35%;
right: 0;
transform: rotate(45deg);
transition: 0.3s;
}
&.open {
&:after {
top: 40%;
transform: rotate(-135deg);
}
}
}
.A {
max-height: 0;
overflow: hidden;
font-size: 15px;
transition: 0.3s;
&.open {
.txt {
opacity: 1;
transform: translateY(0);
}
}
.txt {
padding-top: 15px;
opacity: 0;
transition: 0.5s 0.2s;
transform: translateY(5px);
p {
margin-bottom: 1em;
&:last-child {
margin-bottom: 0;
}
}
}
}
}
}
}
Nice!
COPY
const accordion = Array.from(document.querySelectorAll(".accordion ul li .Q"));
accordion.forEach((item) => {
item.addEventListener("click", function () {
this.classList.toggle("open");
const anser_height = this.nextElementSibling;
anser_height.classList.toggle("open");
if (anser_height.style.maxHeight) {
anser_height.style.maxHeight = null;
} else {
anser_height.style.maxHeight = anser_height.scrollHeight + "px";
}
});
});