[英]CSS Paragraph wrap to next line
I am trying to wrap a paragraph text to the next line when the browser-window is shrinked. 当浏览器窗口缩小时,我试图将段落文本包装到下一行。 Currently, it stays in the same place and a horizontal scroll bar appears when the browser window shrinks beyond the paragraph text. 当前,它停留在同一位置,并且当浏览器窗口缩小到段落文本之外时,会出现水平滚动条。
I tried CSS3 text-wrap property but it didn't work, or maybe I didn't use it right. 我尝试了CSS3文本换行属性,但是它不起作用,或者我没有正确使用它。
You've got your #header div set to a fixed width. 您已将#header div设置为固定宽度。 If you want it to wrap with the browser, set the width using percentages. 如果您希望它与浏览器一起包装,请使用百分比设置宽度。
Change this in your CSS: 在CSS中更改此设置:
#header {
background: url("http://www.domainandseo.com/portfolio/page-view/images/header-bg.jpg") no-repeat transparent;
min-height: 109px;
/* width: 928px; */// <-- remove this line
}
.header-content {
bottom: 15px;
clear: both;
margin-left: 190px;
position: relative;
/* width: 106%; */// <-- remove this line
}
Explanation: Removing the width: 928px
from #header
will cause the header to become 100%
wide, which means "as wide as the browser, so shrink when the browser gets smaller". 说明:删除#header
的width: 928px
将使标题变为100%
宽,这意味着“与浏览器一样宽,因此当浏览器变width: 928px
缩小。” Removing the width: 106%
from #header-content
makes it as wide as it's parent #header
. 删除width: 106%
#header-content
的width: 106%
,使其与父级#header
一样宽。
A side note: using widths that are more than 100% are generally a bad idea, they present strange layout issues that are hard to trace and usually it means that elements end up just outside the viewport, which is almost always undesirable. 旁注:使用大于100%的宽度通常不是一个好主意,它们会带来难以跟踪的奇怪布局问题,通常这意味着元素最终仅出现在视口之外,这几乎总是不希望的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.