div中的行高未按预期工作

时间:2014-10-08 13:29:09

标签: html css

我有一个div,我在其中放置文本,图像,链接等段落,我无法使用行高属性。我使用PHP从数据库中检索此内容。

典型的情况是,

<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;
}

我将内容输入a并将其存储在db中。现在我观察到,无论我在哪里通过按Enter键实际结束我的线,我得到200 px的间隙。不在线之间。基于屏幕分辨率和其他东西,一条线可以在任何地方结束吗?

然而它正在起作用,

enter image description here

编辑1:是的我尝试过自动换行:break-word它不起作用。

2 个答案:

答案 0 :(得分:1)

如果你想破坏句子然后行高可能会起作用,你可以使用它

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

答案 1 :(得分: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>