css - 在 div 中包装一个段落?

标签 css html

如何让我的段落在我的 div 中换行?它目前溢出到 div 之外,我不知道如何阻止该段落溢出边缘。我不想要滚动条:

overflow: scroll;

其他溢出选项在这里似乎也无济于事......我有以下代码:

div {
 width: 1200px;
 margin: 0 auto;
}
.container {
 overflow: hidden;
}
.content {
 width: 1000px;
 float: left;
 margin-left: 0;
 text-align: left;
}
.rightpanel {
 width: 190px;
 float: right;
 margin-right: 0;
 }

<div class="container">
   <div class="content">
   <p>Some content flowing over more than one line</p>
   </div>
   <div class="rightpanel">
   <!-- content -->
   </div>
</div>

编辑:

<div class="container">
<div class="content">
<div class="leftcontent">           
</div>
<div class="newsfeed">
<div class="newsitem">
<p>Full age sex set feel her told. Tastes giving in passed direct me valley as supply. End great stood boy noisy often way taken short. Rent the size our more door. Years no place abode in no child my. Man pianoforte too solicitude friendship devonshire ten ask. Course sooner its silent but formal she led. Extensive he assurance extremity at breakfast. Dear sure ye sold fine sell on. Projection at up connection literature insensible motionless projecting.<br><br>Be at miss or each good play home they. It leave taste mr in it fancy. She son lose does fond bred gave lady get. Sir her company conduct expense bed any. Sister depend change off piqued one. Contented continued any happiness instantly objection yet her allowance. Use correct day new brought tedious. By come this been in. Kept easy or sons my it done.</p>
</div>
</div>
</div>
<div class="rightpanel">
</div>

最佳答案

我明白了!您为所有 div 设置了 1200 像素的宽度。如果你把它拿走,一切都会好起来的。 .newsfeed 和 .newsitem 正在采用此属性。

您也可以给 .newsfeed 和 .newsitem 一个宽度:

.newsfeed , .newsitem { width: 300px; }

例子: http://jsfiddle.net/UZMR2/

关于css - 在 div 中包装一个段落?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4517022/

相关文章:

html - 响应式设计模式与调整浏览器窗口大小

javascript - 一行中的多个 <select> 下拉列表(Foundation css import)

html - safari 不显示带阴影的圆形 div

javascript - 分组表行的 CSS 样式

jquery - 动画图像不会恢复到原来的大小

javascript - React/Nextjs - 知道什么页面在 _app.js 上呈现

javascript - 一起使用 Instafeed 和 SimplyScroll

html - 在菜单中添加子项

css - 如何去掉antd中的默认padding

css - 需要并排对齐 Bootstrap 元素