文本从一个div泄漏到另一个div

时间:2015-01-24 14:49:25

标签: html css

我有2个div分开,每个都有相同的“容器”类和他自己的id。每个div包含文本 - 当我在我的计算机上运行文件时,它的工作正常。但是当我通过我的iPhone打开文件时,上部div中的文本在底部div中泄漏。我担心这会发生在其他设备上。 这是我的代码:

    <div id="about_us" class="container">
<h1>texttexttexttexttexttexttext</h1>
<p>texttexttexttexttexttexttexttexttext</p>
<p>texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext</p>
</div>

<div id="our_services" class="container">
<h1>text1</h1>
</div>

.container{
width: 100%;
height: 500px;
background-color: white;
}
#about_us{
text-align: center;
height: 250px;
font-family:"open_sans_hebrewregular", "alefregular",arial,"Times New Roman";
color:gray;
}

#about_us p{
width: 55%;
margin: auto;
text-align: center;
direction: rtl;
padding-bottom: 10px;
line-height: 30px;
}
#our_services{
height: 450px;
text-align: center;
font-family:"open_sans_hebrewregular", "alefregular",arial,"Times New Roman";
color: black;
background-color: rgb(224,224,224);
}

任何人都知道如何解决这个问题? 谢谢!

1 个答案:

答案 0 :(得分:0)

您可以设置overflow属性,这是使用的示例:overflow: auto; - 一旦文本变得大于固定高度,这将把div变成可滚动的容器:

http://jsfiddle.net/Lrus8oo1/

关于溢出的更多内容:http://css-tricks.com/the-css-overflow-property/

或 -

您可以将.container中的height: 500px;更改为:min-height: 500px; 设置最小高度将允许容器随文本一起增长,因此它不会溢出。

http://jsfiddle.net/Lrus8oo1/1/

相关问题