0

Does anyone know how to use the following css trick with inline-blocks?

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

I have couple of text tags (h2 & h3) on the same line and even if I change the display: block to inline-block, it still messes up the layout.

Has anyone done anything similar?

EDIT: I only want to concatenate the h2 (first element), not the h3 tag content.

forkinspace
  • 124
  • 1
  • 3
  • 16

3 Answers3

1

try this

p{
          display: inline-block;
          width: 100px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
    }
<p class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy 
   </p>
   
satyajit rout
  • 1,623
  • 10
  • 20
0

Try to use line-height for class text with display:inline-block

.text{
          display: inline-block;
          /* adjust line height for class text*/
          line-height: 25px;
          width: 100px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
    }
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy 
   </h2>
   <h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy 
   </h3>
Eng_Farghly
  • 1,987
  • 1
  • 23
  • 34
0

.text {
  display: inline-block;
  line-height:20px;
  width: 200px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h2>
<h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h3>
Deepak Kumar
  • 221
  • 3
  • 17