Jump to content

Alligning text in accordion block

Recommended Posts

Hi all, 

On my website I would like to add a list of information in an accordion element. I would like it to look like following example (made in word) where each topic is answered, but where the answers are indented so they are all aligned. If the answers outrun the length of the text line I would like that the second line is aligned to the rest of the answers. 

image.png.f1b500f2ac1ce5f78309e1054771fc77.png

 

To achieve this i already went though a number of steps. First I made the topic titles bold in the squarespace interface to be able to adress them in code, and added this code in CSS: 

.accordion-item__description strong {
    font-weight: normal;
    display: inline-block;
    width: 150pt;
}

This works in indenting the answers buy a fixed amount, but the problem is that the second line of the anwers jumps back to the front of the line instead of the indent. 

image.png.f9b17d544343b8576fa1ccf59dc83c77.png

 

The second thing I tried, together with the above was making the answers italic in the squarespace interface (to be able to adress them in code) and applying this code in CSS:

.accordion-item__description em {
    font-style: normal;
      position: absolute;
      padding-left: 0pt; 
}

This is  was succesfull in also aligning the second lines of the answer, but it created two additional problems: 

- text start to overlap (when there are multiple two line answers)
- the text starts to overrun the accordion dividers. 

 

image.png.5b810a9a3190335301cd1bb603de85f3.png

 

Does anyone know how to solve this issue? 

Here is the webpage URL where I have been testing: https://www.fallow.eu/work/tilefactory-1

Thanks in advance!

 

Link to comment
  • Replies 1
  • Views 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

On 11/8/2023 at 1:49 AM, Matthias39682 said:

Hi all, 

On my website I would like to add a list of information in an accordion element. I would like it to look like following example (made in word) where each topic is answered, but where the answers are indented so they are all aligned. If the answers outrun the length of the text line I would like that the second line is aligned to the rest of the answers. 

image.png.f1b500f2ac1ce5f78309e1054771fc77.png

 

To achieve this i already went though a number of steps. First I made the topic titles bold in the squarespace interface to be able to adress them in code, and added this code in CSS: 

.accordion-item__description strong {
    font-weight: normal;
    display: inline-block;
    width: 150pt;
}

This works in indenting the answers buy a fixed amount, but the problem is that the second line of the anwers jumps back to the front of the line instead of the indent. 

image.png.f9b17d544343b8576fa1ccf59dc83c77.png

 

The second thing I tried, together with the above was making the answers italic in the squarespace interface (to be able to adress them in code) and applying this code in CSS:

.accordion-item__description em {
    font-style: normal;
      position: absolute;
      padding-left: 0pt; 
}

This is  was succesfull in also aligning the second lines of the answer, but it created two additional problems: 

- text start to overlap (when there are multiple two line answers)
- the text starts to overrun the accordion dividers. 

 

image.png.5b810a9a3190335301cd1bb603de85f3.png

 

Does anyone know how to solve this issue? 

Here is the webpage URL where I have been testing: https://www.fallow.eu/work/tilefactory-1

Thanks in advance!

 

You can consider use flex instead of position absolute

The page doesn't work. Can you check it again?

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.