2014-10-08 86 views
-2

我有一段文本,图像,链接等段落,我无法使用行高度属性。我使用PHP从数据库中检索这些内容。div中的行高不像预期的那样工作

一个典型的情况是,

<div class = "story"> 
Now there are many complaints. We will study the matter... Whether there is a need for a separate policy or some kind of clarification is needed, we will make it clear soon 

Now there are many complaints. We will study the matter... Whether there is a need for a separate policy or some kind of clarification is needed, we will make it clear soon 
</div> 

.story{ 
    line-height: 200px; 
} 

I中的内容到一个输入,并将其存储在一个分贝。现在我观察到,在任何时候我通过按回车身体结束了我的行,我得到了200像素的差距。不在线之间。根据屏幕分辨率和其他事情,一条线可以在任何地方结束?

但它是工作这样的事情,

enter image description here

编辑1:是的,我曾尝试自动换行:打破字这是行不通的。

+1

没有明白这个问题,但你总是可以使用width属性来限制div元素的宽度。也应该是
而不是
。 – albusshin 2014-10-08 13:31:57

+3

你的问题没有意义。 – GolezTrol 2014-10-08 13:32:01

+0

这是因为您使用“行高”来垂直放置文本块?如果是这样,你正在解决错误的问题。 – George 2014-10-08 13:32:39

回答

0

由于您使用了错误的标签,即</br>,因此该行不会中断。你需要使用一个<br/>标签添加换行符:DEMO

HTML:

<div class = "story"> 
    Now there are many complaints. We will<br/> study the matter... Whether there is a need for a<br/> separate policy or some kind of clarification is needed,<br/> we will make it clear soon 
</div> 
1

你可以,如果你想打破这句话,用这个再行高可能工作

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

试过它的人。不起作用。我编辑了这个问题,请再看一遍。 – Aditya 2014-10-08 13:56:47

相关问题