Tips on condensing lengthy text into a single line using Bootstrap 4

I have been searching for a way to truncate long text into a single line in bootstrap 4. I have come across several solutions on Stack Overflow such as Link 1, Link 2, Link 3, but none of them seem to work for me.

Here is the text I am dealing with:

https://i.sstatic.net/WbJyA.jpg

This is the desired output:

https://i.sstatic.net/Snic2.jpg

However, when I implement the following code, the text does not truncate into a single line, and the table line protrudes slightly:

https://i.sstatic.net/9AKR1.jpg

Here is the code snippet I am using:

     <div class="row">
            <div class="font-14">
                <table id="userLogTable" class="table table-striped table-bordered" style="width:100%">
                    <thead>
                        <tr>
                            <th class="text-center">#</th>
                            <th class="text-center">LOG LIST</th>
                            <th class="text-center">DETAIL</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>

    columns: [
        { data : "id", "className": "text-center" },
        { data : "log_info", "className": "text-log" },
        { data : "log_id", "className": "text-center",
            render: function(data) {
                return "...";     
            }
        }
    ],

.text-log {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1; /* number of lines to show */
  -webkit-box-orient: vertical;
}

Answer №1

Adjust the row's height and enable scrolling using overflow:scroll. It should function properly.

ATTR{
  font-size:12px;
  line-height:15px;
  height:30px;
  width:100%;
  overflow:scroll;
  white-space: nowrap;
}

ATTR::-webkit-scrollbar {
    display: none;
}

ATTR {
    -ms-overflow-style: none;
}

Answer №2

Here is a perfect solution for your code:

td.text-log {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1; /* specify the number of lines to display */
  -webkit-box-orient: vertical;
}

Answer №3

To cut off text, you can implement the following CSS snippet:

.text-log {
    display: block; //ensure it's a block element 
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

What is the best way to ensure that empty strings are not included in the length of my array?

I have encountered an issue with a JSON file that I fetch. The array syllables is capable of holding up to strings max. However, when I exclude 2 words, I end up with 2 words and 2 empty strings. Nevertheless, my front-end still expects 4 "strings". So, it ...

Implementing Bootstrap tooltips in content that can be scrolled

I need help with positioning two containers, which you can view in this FIDDLE. Both containers may contain a lot of content, so I have applied overflow: auto to both of them. This is the HTML structure: <div id="maincontainer"> <d ...

Creating an infinite products loader using ajax can be a great way to enhance the

I have encountered a challenging issue that I am struggling to overcome, partly due to my unfamiliarity with the correct terminology. As a newcomer to this field, please forgive the clumsiness of my question. Below is an outline of my objective: Currentl ...

How should HTML5 type "month" be stored in a Django model's database using which data type?

My HTML form includes a field for inputting a month <input type='month' name="last_appraisal" id='txtLastAppraisal' value='2013-12' /> In the Django model, I have defined this field as last_appraisal = models.DateFie ...

JQuery unable to recognize dynamically inserted Anchor Tag through AJAX request

I am currently working on a page that is sourcing a large amount of data from a database through various PHP files. To achieve this, I am using JQuery to identify specific events and trigger AJAX requests to the necessary PHP file to display the required c ...

Prevent submission until all input fields are completed

Seeking guidance on a jQuery script to disable the submit button until all input fields are filled. Here is what I have so far: $(document).ready(function (){ if ($('#inputName, #inputEmail, #inputTel').val().length > 0) { $("input[type=su ...

Toggle visibility of cards using bootstrap

I've been attempting to show and hide a selection of cards in bootstrap, but I'm having trouble figuring it out. All the cards share the class "card," and my goal is to hide them all when a specific button is clicked. Below is my current code: ...

The navigation bar is not extending to fill the entire width of the screen

I recently created a navigation bar using the nav tag and applied CSS to set the width, border, and padding. However, I noticed that there are some empty pixels on each side of the navigation bar that I can't seem to fill up. Here is the HTML code for ...

Troubleshoot: jQuery unable to load JSON data

section, I am working on loading multiple products onto a page section utilizing data from a JSON file. Initially, I implemented this using JavaScript successfully, but I am inclined to switch to jQuery. Despite the absence of errors in the console, the d ...

AngularJS is restricting the use of square brackets within the URL parameter, specifically the character '[.'

My goal is to connect to an external API Everything works smoothly when my parameters are set up like this $http.post('http://api.myprivatebox.com/users.json', { email : email, password : password}).then(function (results) { console.log( ...

Is there a way to eliminate the "x" in the upper right corner of a Foundation Joyride?

Edit 7/16/15: I decided to place the following code between the <li> tags within the joyride that required the removal of the "x" button: <script>$('.joyride-close-tip').remove();</script> While not the most elegant solution ...

What is the best way to create a column that adjusts its width based on the row width in a table?

Here is the code snippet that I am working with: return ( <Box sx={{ height: 400 }}> <DataGrid columns={columns} rows={rows} /> </Box> ) Currently, my table appears like this: https://i.sstatic.net/KWXwL.png I am aiming for the ...

Explore the functionality of the Enter key and search button with JavaScript

I have the following code that works perfectly when I click on the search button. However, I would like to know how I can also initiate a search using the enter key. Here is the code snippet: <script> function mySearch() { var text = document.g ...

How do I switch the background-image on li hover and revert it back when I move off the li element?

Looking to update the background image of a div upon hovering over a li element? Check out this example here. So far, I've got that part working fine. But now I want the background picture to revert back to its original CSS when I move away from the l ...

Why does tagging P trigger popups in the DIV when the DIV contains another DIV?

JSBIN HTML <p> <div>123</div> </p> CSS p div{ background:#f00; } Encountering an odd issue here. When I input the HTML structure as shown below: <p></p><div>123</div> The CSS code fails to produce ...

Aligning images with absolute CSS to text that is wrapping positions the images perfectly alongside the text content

My webpage has a long content section that resizes based on the browser width. Here's an example: <h1 id="loc1">Title</h1> <p>bodycopy bodycopy bodycopy bodycopy bodycopy bodycopy bodycopy bodycopy bodycopy bodycopy bodycopy bod ...

Sending data from an AJAX POST request to a Grails Controller

Currently, I am in the process of developing a social networking platform using Grails. However, I have encountered a roadblock when it comes to allowing users on their edit profile page to input a YouTube URL into a text field. By clicking a button, a Jav ...

Struggling to retrieve the JSON information, but encountering no success

Here is the javascript code snippet: $.getJSON("validate_login.php", {username:$("#username").val(), password:$("#password").val()}, function(data){ alert("result: " + data.result); }); And here is the corresponding php code: <?ph ...

Utilizing jQuery for updating values within an XML document

Upon receiving an XML-like string through a jQuery $.ajax() get request, I encountered issues due to its invalid format preventing the use of dataType:'xml' or $.parseXML(). Despite this, I managed to traverse the xml string successfully using jQ ...

Angular 2 component stays static despite changes in route parameters

So, I am in need of a way to refresh my component after the URL parameter's id has been altered. The following code is from my player.component.ts: import {Component, OnInit, AfterViewInit} from '@angular/core'; import {ActivatedRoute, Rout ...