Home>
↑ Current situation
↓ Ideal
↓ After correction
I was able to display the pseudo element (A) successfully, but the transition to the second line of the text goes under A.
I want to match the indent (?) With "1 content" on the first line, what should I do?
Even if I created an .accordion-content-box one level above the .accordion-content p and added a pseudo element to it, the display was similar.
It was difficult even through trial and error, so sorry to trouble you, but thank you.
<section> Frequently Asked Questions (FAQ) <dl> <dt> 1 title </dt> <dd aria-hidden = "true"> <p>1 content<br>1 content<br>1 content<br>1 content<br>1 content<br>1 content<br>1 content<br>1 content<br></p> </dd> <dt> 2 titles </dt> <dd aria-hidden = "true"> <p>2 Contents</p> </dd> <dt> 3 titles </dt> <dd aria-hidden = "true"> <p>3 Contents</p> </dd> </dl> </section>
.question-content {
height: auto;
min-height: 600px;
background-color: white;
border: 1vw solid # 38cc70;
padding-top: 30px;
}
.question-content-wrap {
max-width: 1080px;
margin: 0 auto;
}
.question-content-wrap-ttl {
text-align: center;
}
.question-content-wrap-ttl h1 {
font-weight: bold;
font-size: 42px;
margin-bottom: 0px;
}
.accordion dd,
.accordion__panel {
background-color: #eee;
line-height: 1.5em;
}
.accordion h2 {
font-size: 23px;
font-weight: bold;
margin-bottom: -7px;
}
.accordion p {
padding: 20px;
margin-bottom: 0px;
}
.accordion p: before {
content: "A";
font-size: 48px;
font-weight: bold;
padding-right: 20px;
line-height: 0.5em;
float: left;
margin-bottom: 0px;
}
.accordion {
position: relative;
background-color: #eee;
}
.question-content-wrap-list-container {max-width: 960px;
margin: 0 auto;
padding: 2em 0 2em 0;
}
.accordionTitle,
.accordion__Heading {
background-color: # 38cc70;
text-align: left;
font-weight: 700;
padding: 20px;
display: block;
text-decoration: none;
color: #fff;
-webkit-transition: background-color 0.5s ease-in-out;
transition: background-color 0.5s ease-in-out;
}
.accordionTitle: before,
.accordion__Heading: before {
content: "+";
font-size: 2.5em;
line-height: 0.5em;
float: right;
-webkit-transition: -webkit-transform 0.3s ease-in-out;
transition: -webkit-transform 0.3s ease-in-out;
transition: transform 0.3s ease-in-out;
transition: transform 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out;
}
.accordionTitle: hover,
.accordion__Heading: hover {
background-color: # 2ba659;
}
.accordionTitle: after,
.accordion__Heading: after {
content: "Q";
font-size: 48px;
padding-right: 20px;
line-height: 0.5em;
float: left;
-webkit-transition: -webkit-transform 0.3s ease-in-out;
transition: -webkit-transform 0.3s ease-in-out;
transition: transform 0.3s ease-in-out;
transition: transform 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out;
}
.accordionTitleActive,
.accordionTitle.is-expanded {
background-color: # 2ba659;
}
.accordionTitleActive: before,
.accordionTitle.is-expanded: before {
-webkit-transform: rotate (-225deg);
transform: rotate (-225deg);
}
.accordionItem {
height: auto;
overflow: hidden;
max-height: 50em;
-webkit-transition: max-height 1s;
transition: max-height 1s;
}
@media screen and (min-width: 48em) {
.accordionItem {
max-height: 15em;
-webkit-transition: max-height 0.5s;
transition: max-height 0.5s;
}
}
.accordionItem.is-collapsed {
max-height: 0;
}
.no-js .accordionItem.is-collapsed {
max-height: auto;
}
.animateIn {
-webkit-animation: accordionIn 0.45s normal ease-in-out both 1;
animation: accordionIn 0.45s normal ease-in-out both 1;
}
.animateOut {
-webkit-animation: accordionOut 0.45s alternate ease-in-out both 1;
animation: accordionOut 0.45s alternate ease-in-out both 1;
}
@ -webkit-keyframes accordionIn {
0% {
opacity: 0;
-webkit-transform: scale (0.9) rotateX (-60deg);
transform: scale (0.9) rotateX (-60deg);
-webkit-transform-origin: 50% 0;
transform-origin: 50% 0;
}
100% {
opacity: 1;
-webkit-transform: scale (1);
transform: scale (1);
}
}
@keyframes accordionIn {0% {
opacity: 0;
-webkit-transform: scale (0.9) rotateX (-60deg);
transform: scale (0.9) rotateX (-60deg);
-webkit-transform-origin: 50% 0;
transform-origin: 50% 0;
}
100% {
opacity: 1;
-webkit-transform: scale (1);
transform: scale (1);
}
}
@ -webkit-keyframes accordionOut {
0% {
opacity: 1;
-webkit-transform: scale (1);
transform: scale (1);
}
100% {
opacity: 0;
-webkit-transform: scale (0.9) rotateX (-60deg);
transform: scale (0.9) rotateX (-60deg);
}
}
@keyframes accordionOut {
0% {
opacity: 1;
-webkit-transform: scale (1);
transform: scale (1);
}
100% {
opacity: 0;
-webkit-transform: scale (0.9) rotateX (-60deg);
transform: scale (0.9) rotateX (-60deg);
}
}
jQuery (function () {
var d = document,
accordionToggles = d.querySelectorAll ('.js-accordionTrigger'),
setAria,
setAccordionAria,
switchAccordion,
touchSupported = ('ontouchstart' in window),
pointerSupported = ('pointerdown' in window);
skipClickDelay = function (e) {
e.preventDefault ();
e.target.click ();
}
setAriaAttr = function (el, ariaType, newProperty) {
el.setAttribute (ariaType, newProperty);
};
setAccordionAria = function (el1, el2, expanded) {
switch (expanded) {
case "true":
setAriaAttr (el1,'aria-expanded','true');
setAriaAttr (el2,'aria-hidden','false');
break;
case "false":
setAriaAttr (el1,'aria-expanded','false');
setAriaAttr (el2,'aria-hidden','true');
break;
default: default:
break;
}
};
// function
switchAccordion = function (e) {
console.log ("triggered");
e.preventDefault ();
var thisAnswer = e.target.parentNode.nextElementSibling;
var thisQuestion = e.target;
if (thisAnswer.classList.contains ('is-collapsed')) {
setAccordionAria (thisQuestion, thisAnswer,'true');
} else {
setAccordionAria (thisQuestion, thisAnswer,'false');
}
thisQuestion.classList.toggle ('is-collapsed');
thisQuestion.classList.toggle ('is-expanded');
thisAnswer.classList.toggle ('is-collapsed');
thisAnswer.classList.toggle ('is-expanded');
thisAnswer.classList.toggle ('animateIn');
};
for (var i = 0, len = accordionToggles.length;i<len;i ++) {
if (touchSupported) {
accordionToggles [i] .addEventListener ('touchstart', skipClickDelay, false);
}
if (pointerSupported) {
accordionToggles [i] .addEventListener ('pointerdown', skipClickDelay, false);
}
accordionToggles [i] .addEventListener ('click', switchAccordion, false);
}
}) ();
-
Answer # 1
-
Answer # 2
to .accordion p
display: flex;
It will be in the desired shape for the time being.
But it's better to have .accordionItem div as the parent of flexbox, put before (large A) attached to p in the original code directly under it, and make it flex item with p element.
Related articles
- html - i want to align the button marks in the center with wordpress
- html - i want to align images and buttons vertically and centered with css
- html - responsive doesn't work
- html - django's {% block content%} doesn't work
- html - i want to align the heights of the elements that are side by side with flex
- html - scss doesn't work
- html - the image doesn't come to the center what should i do?
- html - layout in tag doesn't work
- html - i want to align the left and right centers and set the border bottom of the mouse hover
- html - css height px doesn't work
- html - don't evenly align images and text side by side with flexbox
- html - i want to align the line heads of input tags
- i want to use to hit the ruby code in the htmlerb file, but it doesn't work how can i write ruby code
- html - when i landscape on my iphone, it doesn't fit the width even though i've set a fixed viewport
- html - i want to make a slideshow using slick, but it doesn't work
- html - display:none doesn't work
- html - :placeholder-shown doesn't work for autocomplete
- html - responsive doesn't respond
- html - i want to align the position of form with the left edge
Related questions
- html - i want to change the image size with media queries
- javascript - [html/css] the inverted triangle mark in the select box is overwritten on the background
- html - background image cannot be set
- html - i can't center the input form in django
- html - i can't arrange multiple images side by side with css
- html - i want to display the "+" and "-" of the content that opens and closes the anchor link and accordion
- html - flexbox align specific elements below
- php - i want to be able to appear by clicking the drop-down menu that appears when hovering
- [rails] date cannot be displayed with javascript [html] [css]
For example, add the following