Jump to content

List Section, Description start at the same position

Recommended Posts

Posted

Is there a way to make the description of each content start at the same position, whether the title is 1, 2, 3 lines long? 

You can control the spacing so it's even, but I want the description to start at the same position across each card.

 

Screenshot 2024-11-26 at 2.58.01 PM.png

  • Replies 7
  • Views 262
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

Hi @Elletra To dynamically align the list item descriptions at the same starting position, regardless of the number of lines in the list item titles, you can add this code under Website > Pages > Website Tools > Code Injection > Header.

<script>
document.addEventListener('DOMContentLoaded', function () {
  const titles = document.querySelectorAll('.list-item-content__title');
  let maxHeight = 0;

  titles.forEach(title => {
    maxHeight = Math.max(maxHeight, title.offsetHeight);
  });

  titles.forEach(title => {
    title.style.height = `${maxHeight}px`;
  });
});
</script>

<style>
.user-items-list-item-container[data-title-alignment="left"] .list-item-content__title {
  margin-left: 0;
  margin-right: 0;
}   
  
.list-item-content__text-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px; 
}
</style>

 

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Posted

@Lesum It kinda works, but it makes my titles push to the side. Also can I control the px distance between title and description? These change are on a demo site, so i can't send link, but here is a screenshot.

Screenshot 2024-11-27 at 8.44.29 AM.png

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.