Jump to content

Automatic Line Breaks in Summary Block and Blog Pages

Go to solution Solved by CalifLRev,

Recommended Posts

@tuanphan, if a category was to overflow into a second line, would it be possible to automatically create a line break that sends the entire category to the second line? 

For instance, "Freedman" in the image below automatically overflows into the second line because there's no more space. Is it possible for the full category, "Eli Freedman," to all go on the second line, and not just half of the category?

Screenshot 2023-05-02 at 9.35.37 PM.png

Link to comment
  • Solution

Here's how it's done:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>

<script>
$(document).ready(function() {
  $('.blog-categories').each(function() { // select all elements with class "categories" and loop through them
    $(this).html($(this).html().replace(/\s/g,'&nbsp;')); // replace all white spaces with nbsp
  });
});
  </script>

<script>
$(document).ready(function() {
  $('.summary-metadata-item--cats a').each(function() { // select all elements with class "categories" and loop through them
    $(this).html($(this).html().replace(/\s/g,'&nbsp;')); // replace all white spaces with nbsp
  });
});
  </script>

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.