skip to Main Content

I have an issue with CSS ellipsis for multiline text aligned to right. Is is that, 3 dots – … are hidden. Solution that I have found so far works for the text-align: left; but not text-align: right. Link to code pen here: https://codepen.io/l-k-sfr-jt/pen/dyBvrrW

.

CSS code for multine that works align-right – default.

p {
  -webkit-line-clamp: 3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

Screen shoots
Right text align
Right Align
Left text align
enter image description here


p {
  -webkit-line-clamp: 3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-right {
  text-align: right
}
<ul>
  <li>
    <article>
      <div>
        <img src="https://i.ytimg.com/vi/sAa8QyFkVkI/maxresdefault.jpg" alt="">
      </div>
      <div class="description">
        <h2>4 Ways to Conditionally Add Classes in Angular</h2>
        <p class="text-right">
          Hey there, have you ever needed to programmatically add a class to an element in an Angular application? Like, maybe when a button is disabled, we need a class, but then once it’s enabled, we don’t. Or how about when a form goes from an invalid state
          to valid? Well, good news, this is actually pretty easy to do in angular. In this post I’m going to show you four different ways. First we’ll use a method called class binding. Next we’ll use the ngClass directive. After that we’ll use the @HostBinding
          decorator. And finally, we’ll use the Renderer2 addClass() and removeClass() methods. Let’s get to it!
        </p>
        <footer>
          <a href="https://youtu.be/sAa8QyFkVkI">Read More</a>
        </footer>
      </div>
    </article>
  </li>
  <li>
    <article>
      <div>
        <img src="https://i.ytimg.com/vi_webp/91A4-iYK1zY/maxresdefault.webp" alt="">
      </div>
      <div class="description">
        <h2>Create Dynamic Text on a Path with HTML, SVG, and CSS</h2>
        <p>
          When it comes to incorporating irregular shaped text into web projects, we often end up using images. However, there may be a better way – using inline SVG and CSS to create dynamic, responsive, and accessible graphics directly within our HTML. In this
          post, we’ll walk you through the process of achieving this, ensuring our designs are on point while maintaining accessibility and SEO friendliness.
        </p>
        <footer>
          <a href="https://youtu.be/91A4-iYK1zY">Read More</a>
        </footer>
      </div>
    </article>
  </li>
  <li>
    <article>
      <div>
        <img src="https://i.ytimg.com/vi/QIn-hPJNZK0/maxresdefault.jpg" alt="">
      </div>
      <div class="description">
        <h2>CSS Grid Can Do That?!</h2>
        <p>
          With CSS grid we can do some pretty amazing things. We can easily place grid items in the center of containers both horizontally and vertically. We can stack grid items without positioning or negative margins. We can create complex layouts quickly with
          ease. And we can even animate to unknown heights which used to be near impossible in the past. In this video we’ll look at a few of my favorite grid provided abilities.
        </p>
        <footer>
          <a href="https://youtu.be/QIn-hPJNZK0">Read More</a>
        </footer>
      </div>
    </article>
  </li>
  <li>
    <article>
      <div>
        <img src="https://i.ytimg.com/vi/PlldXyuTnUw/maxresdefault.jpg" alt="">
      </div>
      <div class="description">
        <h2>Styling HTML Radio Buttons: A Step-by-Step Guide</h2>
        <p>
          HTML radio buttons are a staple of web forms, but their default appearance leaves much to be desired. In this blog post, we’ll walk through one of my favorite methods to customize the look of radio buttons using CSS, creating a more user-friendly and
          visually appealing experience.
        </p>
        <footer>
          <a href="https://youtu.be/PlldXyuTnUw">Read More</a>
        </footer>
      </div>
    </article>
  </li>
</ul>

codepen

2

Answers


  1. The three "…" is still there, the problem is the space remaining to set the text in the right side, if you gave width to the "text-right" and varies it to different width in the inspect element you can clearly see the three dots in the end. It depends upon different size of the screen, on some screen sizes we can see the three dots but in other it is not visible due to the length of the text.

    Login or Signup to reply.
  2. A workaround would be to add a padding and a negative margin to the right, like so:

    .text-right {
        padding-right: 20px;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search