我的布局是这样的:
<section class="container">
<div class="picture-div">
<figure><img src="blah"></figure>
<figure><img src="blah"></figure>
...
</div>
<div class="text-div">
<p>Text which could be very very very very very very very very very very very very very very very very very very long</p>
<p>Text which could be very very very very very very very very very very very very very very very very very very long</p>
...
</div>
</section>
picture-div 和 text-div 都根据其内容具有动态宽度。picture-div 的最小宽度为 500px,text-div 的最小宽度为 300px。
我想要一个符合以下规则的动态效果:
- 容器后面的元素应该清除浮动并且内容完全低于容器元素。
- 如果视口宽度不够,水平滚动条应始终放置在 HTML 元素上,而不是容器、picture-div 或 text-div 元素上。
- 如果容器宽度超过(picture-div width + 300px),text-div 会浮动在picture-div 的右侧并占据容器的整个左侧空间。(例如,如果容器宽度为 2000 像素,图片 div 宽度为 800 像素,则图片 div 为 800 像素,文本 div 为 1200 像素。)
- 如果容器宽度不超过(picture-div 的宽度 + 300px),则 text-div 不会浮动,并且 picture-div 和 text-div 都会占用整个容器空间。(例如,如果容器宽度为 1000px,picture-div 宽度为 800px,那么picture-div 和 text-div 都取 1000px)
有没有一个纯 CSS 解决方案?