css - 防止div折断击落

标签 css

当在下面的示例中调整窗口大小时,是否可以防止 .small 折断并击落,并使其和 .big 保留在原处他们是?

我计划使用媒体查询来更改较小屏幕的布局,但现在 .small 在达到媒体查询分辨率之前就中断了,从而使用户体验不太愉快。

http://jsfiddle.net/7q9jbuns/

.main {
    display: table;
    border: 1px solid black;
}
.big {
    float: left;
}
.small {
    float: right;
}
<div class="wrapper">
    <div class="main">
        <p>Using display table so the box will wrap to this text</p>
        <p>Ref. <a href="http://stackoverflow.com/questions/27190514/making-divs-inside-flex-boxes-shrink-wrap">StackOverflow #27190514</a></p>
        <div class="big">
            <img src="http://placehold.it/200/200" />
        </div>
        <div class="small">
            <img src="http://placehold.it/50/50" />
        </div>
    </div>
</div>

最佳答案

一种解决方案是向 .main 添加一个 min-width,其宽度需要防止其换行。

http://jsfiddle.net/xqg3r8f3/

关于css - 防止div折断击落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30959166/

相关文章:

html - 引导左侧边栏,内容右侧

HTML 电子邮件 BG 颜色问题

html - 将 PSD 边距转换为 HTML/Bootstrap

html - 页脚没有停留在页面底部

jquery - 如何知道 ul 的下一个 li 有内容

jquery - 显示隐藏元素后的粘性侧边栏

css - CSS 初学者 style=border

html - 使用 CSS 使文本溢出到左侧

html - 对齐 &lt;textarea&gt; 右上角的 <p> 标签?

css - 为什么我的 `span` 这么宽?