简体   繁体   English

在CSS div中换行

[英]wrapping text in css div

Hi guys for some reason my text is not wrapping in Div , I have three divs placed inline-block and floating left . 嗨,大家好,由于某些原因,我的文本没有在Div换行,我将三个div放在inline-blockfloating left If i don't use floating left the the divs gets pushed down. 如果我不使用左浮动,则div将被下推。

CSS code CSS代码

#OuterSection
{
border-top: 10px solid #0272b0;
border-left: 5px solid #0272b0;
border-bottom: 5px solid #0272b0;
border-right: 5px solid #0272b0;
border-radius: 10px;
background-color: #0272b0;
width:250px;
height: auto;
display:inline-block;
}

#InnerSection
{
width:auto;
height:auto;
text-align:center;
background-color: #FFF;
border-radius: 5px;   
text-align:left;
word-wrap: break-word;
float:left;
}

#SectionTitle
{
color: #FFF;
display: inline-block;
font-weight: bold;
margin-bottom: 5px;

}

HTML code here HTML代码在这里

<div id="OuterSection">
<span id="SectionTitle">section1</span>
<div id="InnerSection">

 testtesttesttesttesttesttesttesttesttesttesttest

</div>
</div>

<div id="OuterSection">
<span id="SectionTitle">section2</span>
<div id="InnerSection">

</div>
</div>

<div id="OuterSection">
<span id="SectionTitle">section3</span>
<div id="InnerSection"></div></div>

#Section{display:inline-block;}

Fix can be found here: DEMO 可以在此处找到修复: DEMO

Used word-wrap:break-word; 二手word-wrap:break-word; on your innerSection with width:100%; 在您的innerSection上, width:100%;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM