What is the best solution for adjusting spacing in justified text columns within bootstrap?

As I work on creating a div with two columns, I am facing an issue with maintaining justified alignment. It looks great with two divs using col-lg6- in Bootstrap, but when I switch to col-md-6 or col-sm-6, there are excessive spaces between words to keep the alignment consistent with varying word lengths.

Here is a link to some image samples.

1) I've attempted a pure CSS solution:

#third-div{
background-color: #904e45;
text-align: justify;
column-count:2;
-webkit-column-gap: 40px;
-moz-column-gap: 40px;
column-gap: 40px;
}

2) I also tried using word-break: break-all;, but this method breaks words without following proper grammatical rules.

3) Currently, I am exploring the option of using two Bootstrap cols within a Bootstrap row, like this:

<div id="third-div" class="page-div">
      <div class="row">
        <div class="col-lg-6 col-md-6 col-sm-6">
          <h1>Lots of text</h1>
          <h2 class="fio">But divided into two columns</h2>
          <p>Some more text goes here.</p>
        </div>

        <div class="col-lg-6 col-md-6 col-sm-6">
          <p>Some more text goes here.</p>
        </div>

      </div>


    </div>

.page-div{
  padding: 15%;
  padding-left: 15%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

#third-div{
  background-color: #904e45;
  text-align: justify;
}

Answer №1

Understanding how text-align: justify functions is key. It evenly spaces out words to maintain text justification, disrupting this would result in an unjustified appearance.

An effective solution may involve condensing content into a single column for smaller screens.

<div id="third-div" class="page-div">
    <div class="row">
        <div class="col-lg-6 col-md-12 col-sm-12">
          <h1>A Vast Amount of Text</h1>
          <h2 class="fio">Divided into two columns</h2>
          <p>Numerous lines of text here</p>
        </div>

        <div class="col-lg-6 col-md-12 col-sm-12">
          <p>Several lines of text here</p>
        </div>
    </div>
</div>

This arrangement allows content to align in a single column on smaller screens, providing ample space for text justification optimization.

Answer №2

When using certain browsers like FireFox, it is possible to adjust the spacing by setting the justification to use letter spacing instead of the default word spacing. This feature works similarly to adjusting kerning in design software such as InDesign. Personally, I find it to be more visually appealing for text displayed in narrow columns. For more information, you can check out the Text-Justify article on CSS-tricks. https://i.sstatic.net/s5biM.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Extracting the content within an HTML element through parsing

I am looking to extract the content inside these two elements and store it in a string: source_code = """<span class="UserName"><a href="#">Martin Elias</a></span>""" >>> text 'Martin Elias' Could someone guide ...

Adjust the alignment of two headers with varying sizes

Can someone provide guidance on aligning two headers of different sizes (e.g. h3 and h5) based on their bottom edges, making them appear like a cohesive group in a sentence format? The current code snippet I am working with is as follows: ...

SurveyJs Input component with additional feature

Currently working on a project using ReactJS and surveyjs. I am interested in incorporating an input element for capturing percentage values (%). I am curious if there is a solution for this: Integrating a bootstrap addon or similar feature with surveyjs ...

The mobile display does not support scrolling in Material-UI Drawer

I recently implemented the React Material UI library and integrated the Drawer component as a side-bar menu in my project. However, I encountered an issue where the Drawer component does not support scrolling on mobile devices. You can check out the websi ...

The fixed navigation bar shows a flickering effect while scrolling at a slow pace

Currently facing a challenge with our sticky navigation. Noticing a flickering issue on the second navigation (sticky nav) when users scroll down slowly. The problem seems to be specific to Chrome and Edge, as it doesn't occur on Firefox, IE11, and S ...

The Issue with jQuery Masked Input Functionality

Currently, I am utilizing the jQuery masked input plugin version 1.2.2 created by DigitalBush. Upon applying masks like: $(".phone").mask("(999)-999-9999"); $(".zip").mask("99999?-9999"); to input boxes, I have noticed some peculiar behavior. Essential ...

Save the user input to a dedicated text file

I am working with a couple of select tags that generate an array. Previously, I was only logging the array to the console upon pressing the SUBMIT button, but now I want to save it to a separate text file. Here is my main.html code: <form method="POS ...

What is the best way to send information from an MVC controller to JavaScript?

Being new to programming, I am working on 2 projects that function as client-server via Rest API. I am looking to create a column chart using data from a List of ID (participant) and Votes (Total votes) obtained from the server's connection with the d ...

Ways to align the navigation icon to the left side

I need help positioning my help icon at the bottom of the screen, regardless of the user's monitor size. I've tried using margin and margin-top, but it doesn't adjust properly when changing monitor sizes. Any suggestions or assistance would ...

Deleting database information using Jquery when a div is clicked

I'm looking to create an alert system where users will see a pop-up alert on their screen. However, I am facing a major issue in removing the div completely. I understand that I need to remove it from the database, but I'm struggling with finding ...

Positioned in the middle is a collection of left-aligned divs

While many questions address similar issues, the focus is always on having all items centered (accomplished by using display:inline-block). However, my requirement is to have the last line of items floated neatly left and only center the container itself ( ...

What is causing the error message stating that the DateTime class object cannot be converted to a string?

I found this code snippet on a programming forum function increaseDate($date_str, ${ $date = new DateTime($date_str); $start_day = $date->format('j'); $date->modify("+{$months} month"); $end_day = $date->format(&apo ...

a basic three-tier flexible design with alignment to the lower right side

I am looking to create a dynamic header that adjusts based on the height of the svg logo and available width for the navigation: layout1: https://i.sstatic.net/Oa8gB.png If there is not enough space for all navigation buttons (a) to fit in one row next t ...

As the page is scrolled upwards, the custom cursor's location shifts accordingly

In developing a custom hover cursor for my video div, I am encountering an issue where the cursor does not move with my mouse and remains in place when I scroll. Could someone please review my code and identify what I am doing wrong? Additionally, I have ...

How many hyperlinks are there on this webpage?

Is there a way to determine the number of links on a web page without counting social media networks like Google, LinkedIn, Facebook, and Twitter? ...

The minification of HTML scripts may cause problems with the <script> tag

Greetings! I have a PHP script that is used to minify the page by removing any comments or spaces. Here is the script: <?php function sanitize_output($buffer) { $search = array( '/\>[^\S ]+/s', '/[^&b ...

Is there a way to bring in a variable from the front end script?

Is it possible to transfer an array of data from one HTML file to another? If so, how can this be done? Consider the following scenario: First HTML file <script> let tmp = <%- result %>; let a = '' for (const i in tmp){ ...

Can JavaScript be utilized to dynamically adjust the size of all elements on the screen to a specified percentage of their initial height and width when a certain event occurs?

I'm fairly new to the world of JavaScript, but I have a basic understanding of it. I want to optimize my personal website for mobile devices. I've already taken care of screen orientation and element positioning, everything is centered nicely and ...

HTML - Using Tables to Add and Edit Rows

Take a look at this demo on JSFiddle for my project: Demo jsfiddle I'm currently in the process of creating a table with various functionalities. The function "sortTable" is responsible for sorting the table and it's functioning as expected. T ...

Guide on incorporating an external HTML file into an ASP.NET webpage

Is there a way to incorporate an external HTML file into a ASP.NET web page? In PHP, we typically use the include function for this purpose. I am looking for a similar solution in ASP.NET as well. My goal is to have a shared header HTML file that can be ...