CSS 使段落文本环绕在 div 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7166064/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Making a paragraph text wrap inside a div
提问by echowhiterabbit
I read this post here. I have one simple goal. I just want my text to wrap one time in IE 9. There are only two lines and I need it to wrap from the first to the second. This can not be complicated. I tried adding wrap-text:normal to the supporting div but this did not work. The layout is simple - bascially I have a div containing an image a link and a paragraph. I need the paragraph to wrap inside the div. The text is limited so it will only wrap once.
我在这里阅读了这篇文章。我有一个简单的目标。我只是想让我的文本在 IE 9 中换行一次。只有两行,我需要它从第一行换行到第二行。这不能复杂。我尝试将 wrap-text:normal 添加到支持的 div 中,但这不起作用。布局很简单 - 基本上我有一个包含图像、链接和段落的 div。我需要将段落包裹在 div 内。文本是有限的,所以它只会换行一次。
The image show that when it exceeds the div width it breaks in a way that is strange.
该图像显示,当它超过 div 宽度时,它会以一种奇怪的方式中断。
There are alot of SO posts regarding this but they look like a spider web of info. I'm considering redesigning the mini-feed from the ground up unless someone has a quick fix for this seemingly simple issue.
有很多关于此的 SO 帖子,但它们看起来像一个信息蜘蛛网。我正在考虑从头开始重新设计迷你提要,除非有人能快速解决这个看似简单的问题。
回答by echowhiterabbit
maybe this can help you by a little.. :)
也许这可以帮助你一点点.. :)
<img src="image.jpg" width="50" height="50" style="float:left;" /><div style="float:left; width:200px; max-width:200px; word-wrap:break-word;">Your text here.</div>
I hope that can help you.. CMIIW ^_^
希望能帮到你..CMIIW ^_^
回答by Michael
You mean something like word-wrap: break-word
? Example: http://jsfiddle.net/zCQFb/It doesn't wrap it only one time though.
你的意思是这样的word-wrap: break-word
?示例:http: //jsfiddle.net/zCQFb/它不会只包装一次。
回答by Jason Gennaro
Can you make the paragraph
a set width
?
你能做paragraph
一套width
吗?
If so, make it the width
of the div
or a bit smaller and it should work out.
如果是这样,使它的width
的div
或有点小,它应该工作了。
I would need to see the code (HTML and CSS) to offer a more detailed answer.
我需要查看代码(HTML 和 CSS)才能提供更详细的答案。