使文本包装在绝对定位的div内 [英] Make text wrap inside an absolutely positioned div

查看:167
本文介绍了使文本包装在绝对定位的div内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绝对定位的div与文本内部,但它溢出的宽度的边缘。如果我使用overflow:hidden然后溢出消失。但是,我希望文本在高度的整个范围内包裹多行。

I have an absolutely positioned div with text inside it but it overflows over the edge of the width. If i use overflow:hidden then the overflow disappears. However, I want the text to wrap over multiple lines over the span of the height.

我缺少这里的东西吗?感谢。

Am I missing something here? Thanks.

#absolute_div
{
background-color: #8cc63f;
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
padding: 0px 5px 0px 5px;
width: 44px;
height: 50px;
}


推荐答案

文本是包装;然而,你设置了一个高度。刚性高度将保持 div 不会扩展,这是我假设你想要的。封装和填充空格的文本大小取决于您的 line-height font-size

The text IS wrapping; however, you've set a height. A rigid height will keep the div from expanding, which is what I assume you wanted. The amount of text that wraps and fills the space is greatly going to depend on your line-height, font-size and any other CSS you may have applied to the contents of the container.

在fiddle中我分叉,我设置 font-size:10px; line-height:1 - 有5个换行文本,其余的内容被您在声明中设置的height / width参数隐藏。

In the fiddle I forked, I set font-size:10px; line-height:1 - got 5 wrapping lines of text and the remaining contents are hidden by the height/width parameters you set in you declaration.

http://jsfiddle.net/Kbzga/

word-wrap white-space overflow:visible 可能不是你的后,除非你不介意的44x50绿色框与文本溢出它或滚动条。 HTH

word-wrap, white-space, overflow:visible are probably not what you're after unless you don't mind the 44x50 green box with text spilling out of it, or scrollbars. HTH

这篇关于使文本包装在绝对定位的div内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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