CSS float 元素不相邻

标签 css

请看:http://jsfiddle.net/yCrA8/

蓝色侧边栏应该漂浮在红色中间框旁边,但它正在清除它并位于下方...

我该如何解决这个问题?我无法为 .Middle div 设置宽度,因为它的内容需要在浏览器 View 之外流动并且可以滚动。

干杯

最佳答案

参见: http://jsfiddle.net/thirtydot/yCrA8/4/

一种方法是使用display: inline-blockwhite-space: nowrap

.Sidebar.Middle 中删除 float: left,然后添加:

.MainContent {
    white-space: nowrap
}
.Sidebar, .Middle {
    white-space: normal;
    vertical-align: top;
    display: inline-block;
    /* if you need ie6/7 support */
    *display: inline;
    zoom: 1
}

关于CSS float 元素不相邻,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7385832/

相关文章:

html - CSS 定位有问题

HTML5/CSS3 在进行单选后显示/弹出运动图像

php - 如何在PHP邮件功能中发送图像

html - 三星平板电脑/Moodle 上的 css、 body 背景图像顶部

html - 代码在 Codecademy 上完美呈现,但在 Firefox 中的本地主机上却不完美,有什么不同?

html - 表中的图像不对齐,即使有 cellpadding ="0"

html - 响应式下拉菜单?

css - 设计灵活的页面布局

javascript - 当我在页面中间或页面末尾时如何使用 Angular 2 将页面滚动到顶部

HTML/CSS - 即使使用 <br> 标签,元素也保持在同一行