In Laravel, the text-overflow:ellipsis property fails to function properly when trying to display unescaped data

Encountering an issue with the property text-overflow:ellipsis.

The ellipsis at the end of the truncated text is not showing up as expected.

To maintain formatting without escaping data in ckeditor, I am using:

{!! $treatment->description !!}

specifically for the Description column.

This snippet represents my code:

<table id="tabledata" class="table table-striped hover" style="width:100%">
            <thead>
                <tr>
                    <th></th>
                    <th>Title</th>
                    <th>Description</th>
                    <th>Stay</th>
                    <th>Price</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($treatments as $treatment)
                <tr>
                    <td></td>
                    <td class="p-4">{{ $treatment->title }}</td>
                    <td class="p-4"><span class="descresize">{!! $treatment->description !!}</span></td>
                    <td class="p-4">{{ $treatment->duration }} </td>
                    <td class="p-4">{{ $treatment->price }} €</td>
                    <td>
                        <a class="btn btn-primary" href="{{route('treatment.edit', compact('treatment'))}}" role="button">Update</a>
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>

CSS

.descresize{
    display: inline-block;
    width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;    
}

Seeking assistance to resolve this perplexing issue. Any help would be greatly appreciated!

Answer №1

When using Laravel's Blade Templating engine, the {!! !!} syntax allows for unescaped content to be output, which can include HTML tags. This is especially useful when working with CKEditor, as shown in the example below:

<span class="descresize">{!! $treatment->description !!}</span>
<!-- <span class="descresize"><p>Something something long description of the associated Treatment</p></span> -->

In the scenario where CSS properties are applied to the

<span class="descresize">
element, and this element now contains nested HTML like
<span class="descresize"><p>...</p></span>
, there may be issues with the propagation of these properties to the nested elements.

To ensure proper styling, it is recommended to target the specific nested element directly in your CSS rules, like so:

.descresize > p {
  display: inline-block;
  width: 500px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;    
}

By focusing on the <p> tag within the

<span class="descresize">
, which only contains text and no further nested elements, you should achieve the desired styling results consistently.

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

Issue with JQUERY where HTML select element is not visible

$(document).ready(function(){ var selArr = [ {val: 'corsair', text: 'Corsair'}, {val: 'evga', text: 'EVGA'}, {val: 'antec', text: 'Antec'} ]; $('#pSupply& ...

How can you determine the number of times a particular digit appears around a specific position in a TypeScript array

(Utilizing Typescript for assistance) I am looking to determine the number of occurrences of the digit 2 surrounding a specific position within an array. The function takes in the position coordinates as parameters - param 1 for row and param 2 for column. ...

Modify the hover color of the FontAwesome span icon

Here's a span that I have: <span class="fa fa-green fa-arrow-circle-o-right" aria-hidden="true"></span> I decided to change the color to #008d4c like this: .fa-green { color: #008d4c; } But when I try to hover over it, the color do ...

Is there a way to apply a custom CSS to Bootstrap without altering its appearance?

Check out this code snippet <link rel="stylesheet" href="css/bootstrap.css"> <link rel="stylesheet" href="css/sub-cat.css"> I am having trouble with my CSS. I tried to modify the "Caption" class in Bootstrap by adding some new styles in "sub- ...

What is the best method for submitting an ajax form post when it is dynamically loaded within a bootstrap modal window?

Need some help with a Bootstrap modal form that is not submitting via AJAX as intended. When the form is submitted, the entire page reloads instead of having the data posted in the background. How can I fix this while keeping the page state? Below is the c ...

Unable to verify authentication in Dusk with Sanctum

I'm facing an issue while trying to implement a login page using Laravel Sanctum and React. Although I am able to login in my browser (and see the 'authenticated' message), I encounter difficulties logging in with Dusk. To be precise, I ca ...

Designing a carousel-style menu list with navigation buttons for moving forward and backward

I'm running into some trouble while attempting to create a carousel. Firstly, the issue I am facing is that when you continuously click on the Next button, the function keeps working even after reaching the last item. I'm not sure how to make th ...

Is there a way to adjust paragraph sizes in CSS flexbox so they scale with the font size?

After spending hours trying to figure this out on my own, I finally caved and registered on StackOverflow. Despite Google providing plenty of related questions and examples, I still can't find a solution to my specific problem. The issue at hand is c ...

How to access a variable from within a Phonegap DB function and return it outside of the

I'm struggling with a phonegap db JavaScript script that isn't returning the final string variable "feeds" outside the function. It's currently showing as "undefined". I need help making the necessary changes to properly return the "feeds" v ...

Leverage Bootstrap to apply margins to a container

I'm creating a new blog platform and I need some advice on how to properly position the blog post div in relation to the date div so it displays with the appropriate gaps. https://i.stack.imgur.com/oLbCq.jpg https://i.stack.imgur.com/CqV7b.png Here& ...

I require adding a new line of information into the database table

I am looking for help with adding data into a table without any user inputs. Specifically, I want to add data by passing them into an array and then be able to call them at the "Add Site" button so that the row is added into the table. Can someone assist m ...

What causes divs to be interspersed among other divs when Float is enabled?

I am looking to create a layout for 4 sections, similar to a table, utilizing only divs and CSS. The intended output is this: Logo-----------Info Business-------Client I initially thought it would be simple by using the Float property. However, when I se ...

Utilizing Jquery within a Personalized Post Layout

Being a beginner in jquery, I managed to create this functionality - http://jsfiddle.net/t2x9G/3/ Currently working on a Wordpress project and exploring ways to have the dynamic text content pulled from a post rather than hardcoded in the script. $(&apos ...

SASS fails to recognize the variable

I am trying to incorporate borders based on specific @media breakpoints. Here is the code I have written: @media(max-width:767px) { $height: auto; $grid: 1; } @media(min-width: 768px) and (max-width:991px) { $height: 370px; $grid: 2; } @media(min-width: 9 ...

Invisible Thinglink image revealed upon resizing browser

I am currently repurposing a pre-existing theme that has a drop-down menu showcasing an image. I am attempting to integrate a Thinglink into the content section of this drop-down, but unfortunately, the image does not appear until I adjust the size of the ...

What is the best way to insert HTML elements onto a webpage and retrieve them in an asp.net environment?

Greetings, For the past day, I've been attempting to dynamically add elements to a web page using Visual Studio and access their values. Either I'm overthinking things, being foolish, or there just isn't a straightforward way to achieve wha ...

"Maximizing Bootstrap Functionality with Angular 2: Step-by

I'm experiencing an issue with Angular2, Bootstrap 3.3.7, and Bootstrap Plugins. I have imported all the necessary stylesheets and JavaScript files in the 'index.html' file. Below is the snippet from the index.html: <!-- Bootstrap & ...

Is it true that Laravel Vue Components can solely transmit numerical values?

When working on my UserMenu.vue component, I encountered an issue. Here is the code snippet from UserMenu.vue: export default { props: ['nameVal'], data () { return { } } } Then, in the blade. ...

What is the best way to ensure these 2 divs are aligned vertically in the provided html (starting at the same vertical level)?

<div class="container"> <div class="row"> <div class="col-lg-12"> <div class="news-title"> <h3 class="title">NEWS & ARTICLES</h3> ...

Adding text to a horizontal scrolling element causes the parent div to be pushed downwards

Can anyone help me understand why inserting text into one of the divs in a horizontally scrolling div causes the parent div to move downward? Looking for suggestions! @import url('https://fonts.googleapis.com/css?family=Hind:300,400,500,600,700&apo ...