jQuery/CSS-根据固定宽度换行 [英] jQuery / Css - Wrap the text according to fixed width

查看:110
本文介绍了jQuery/CSS-根据固定宽度换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个p标签,用作我的图像标签.

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.

我需要某种方式,我可以根据图像宽度设置p标签的宽度,并将多余的文本包装在p标签内(转到下一行). 知道如何通过任何方式实现这一目标吗? 感谢任何帮助...

I need some way where i can set the width of the p tag according to the image 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...

使用html更新:

我的图片在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>

然后我使用jquery附加标签

And i later append the label using jquery

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

推荐答案

您可以使用word-wrap属性来实现.

You can achieve it with the word-wrap property.

CSS

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

这篇关于jQuery/CSS-根据固定宽度换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆