您可以将word-wrap
CSS 属性与 一起使用width
,您将得到您想要的。
这是解决方案。
的HTML:
<div id="top">
<div id="top-border">abc</div>
<div id="op-menu"> <jdoc:include type="modules" name="top-menu" style="well" />def</div>
</div>
CSS:
#top {
width:100%;
height:40px;
overflow: hidden;
}
#top-border {
background: url(../images/border.png) repeat-x scroll 0px 18px red;
position: relative;
/*width:74%;*/
height:40px;
float:left;
overflow: hidden;
width: 20px;
word-wrap: break-word;
}
#top-menu {
margin:0;
float:right;
height:40px;
padding-top:6px;
}
我希望这有帮助。
编辑
如果宽度必须是动态的。这是解决方案。
的HTML:
<div id="top">
<div id="top-border">The Quick Brown Fox jumps Over The Lazy Dog. The Quick Brown Fox jumps Over The Lazy Dog. The Quick Brown Fox jumps Over The Lazy Dog. The Quick Brown Fox jumps Over The Lazy Dog. The Quick Brown Fox jumps Over The Lazy Dog. </div>
<div id="op-menu"> <jdoc:include type="modules" name="top-menu" style="well" />def</div>
</div>
CSS:
#top {
width:100%;
height:40px;
overflow: hidden;
}
#top-border {
background: url(../images/border.png) repeat-x scroll 0px 18px red;
position: relative;
/*width:74%;*/
height:40px;
float:left;
overflow: hidden;
width: 97%;
word-wrap: break-word;
}
#top-menu {
margin:0;
float:right;
height:40px;
padding-top:6px;
}
我希望这对现在有所帮助。
编辑 - 2
这是没有定义任何宽度并根据其拥有的内容独立移动框的解决方案。
的HTML:
<div id="top">
<div id="top-border">The Quick Brown Fox jumps Over The Lazy Dog. The Quick Brown Fox jumps Over The Lazy Dog. The Quick Brown Fox jumps Over The Lazy Dog. The Quick Brown Fox jumps Over The Lazy Dog. The Quick Brown Fox jumps Over The Lazy Dog. </div>
<div id="top-menu"> <jdoc:include type="modules" name="top-menu" style="well" />def</div>
</div>
CSS:
#top {
width:100%;
height:40px;
overflow: hidden;
display:table-row;
}
#top-border {
background: url(../images/border.png) repeat-x scroll 0px 18px red;
position: relative;
/*width:74%;*/
height:40px;
display:table-cell;
}
#top-menu {
margin:0;
height:40px;
padding-top:6px;
background:green;
display:table-cell;
}
希望现在有帮助。