开发者

jQuery / Css - Wrap the text according to fixed width

开发者 https://www.devze.com 2023-04-12 09:04 出处:网络
I have a p tag which serve as the label for my images. Currently if the text inside the paragraph is longer than the width of my images, the label will just \"expand\" and exceed my image width.

I have a p tag which serve as the label for my images.

Currently if the text inside the paragraph is longer than the width of my images, the label will just "expand" and exceed my image width.

Since my images could be very close to each other, the label become overlapped.

I need some way where i can set the width of the p tag according to the imag开发者_StackOverflowe width, and wrap extra text inside the p tag (bring to the next line). Any idea how to achieve this by anyway?? Appreciate any help...

UPDATE with html:

My image is inside a div

  <div id="Large1_1317379107949"class="image" style="position: absolute; top: 550px; left: 351.549987792969px;"><img id="Large1_1317379107949"src="../../Content/ContainerImg/Large1.png"style="width: 140px; height: 191px;" /></div>

And i later append the label using jquery

 <p id="129">Large Cabinet</p>


You can achieve it with the word-wrap property.

CSS

   .break-word {
      word-wrap: break-word;
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消