[英]Fluid floated div with text wrapping
I have a container with 2 divs floated side by side. 我有一个2格并排漂浮的容器。
The first div does not have a fixed width applied while the second does. 第一个div没有固定的宽度,而第二个div没有固定的宽度。 What I want is for the first div to expand full width when the 2nd div is not rendered.
我想要的是第一个div在不呈现第二个div时扩展全宽。
However the issue I face is that when a paragraph in div 1 gets to long it does not wrap as it should and instead ends up wioth div1 wrapping under div2. 但是我面临的问题是,当div 1中的段落变长时,它不会按原样进行换行,而是以div1下的div1换行结束。 What I am looking to achieve is for the long paragraph to wrap in div 1 and respect the floated div 2.
我希望实现的是将较长的段落放在div 1中并尊重浮动的div 2。
Code below may explain better.... 以下代码可能会更好地说明...。
<div style="width:600px; height: 600px; margin-left: auto; margin-right: auto; border:1px solid blue;">
<div style="float:left; border:1px solid green;">
<p>Main long text jhjkhjkhjkhjk hj hjkh jkh jkh jkh jkh jkh jk hjk h jkh jh jkh jkh jkh jk hjk hjk hjkhkjhjkhjkhjkhjkhjkhjkhjkhjkhjkhjkh</p>
</div>
<div style="float:right; border:1px solid red; width: 200px;">
<p>Secondary</p>
</div>
thanks in advance 提前致谢
add width to first inner div 将宽度添加到第一个内部div
<div style="width:600px; height: 600px; margin-left: auto; margin-right: auto; border:1px solid blue;">
<div style="float:left; border:1px solid green; width: 396px;">
<p>Main long text jhjkhjkhjkhjk hj hjkh jkh jkh jkh jkh jkh jk hjk h jkh jh jkh jkh jkh jk hjk hjk hjkhkjhjkhjkhjkhjkhjkhjkhjkhjkhjkhjkh</p>
</div>
<div style="float:right; border:1px solid red; width: 200px;">
<p>Secondary</p>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.