【发布时间】:2016-03-20 06:18:04
【问题描述】:
目前我在 div 中有一个段落。当在移动模式(768px)下查看时,我将一个长文本作为段落添加到 div 中。当我用短文本(例如“Box One”)替换长文本时,它不会拉伸 div,因为我没有超过 div 宽度。在移动模式下查看时,如何使段落达到 div 宽度时换行?我已附上我的 jsfiddle 作为示例。
https://jsfiddle.net/ModestGrey/az4ca9j8/
HTML
<div class="boxes">
<div class="one box"><p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p></div>
<div class="two box"><p>Box Two</p></div>
<div class="three box"><p>Box Three</p></div>
<div class="four box"><p>Box Four</p></div>
</div>
CSS
.boxes {
width: 50%;
margin: 0 auto;
}
.box {
display: inline-block;
width: 24%;
height: 15em;
color: #fff;
}
.one {
background: #333;
}
.two {
background: #fff;
color: #333;
}
.three {
background: #aaa;
}
.four {
background: #dc002e;
}
@media only screen and (max-width:48em) {
.boxes {
display: table;
width: 100%;
}
.box {
display: block;
width: 100%;
}
.three {
display: table-caption;
}
.four {
display: table-caption;
}
.one {
display: table-caption;
}
.two {
display: table-caption;
}
}
【问题讨论】:
标签: html css mobile responsive-design paragraph