css - 并排框 : how to make one slide underneath?

标签 css

想象两个并排的盒子。 右侧向右浮动,宽度固定,包含一张照片,左侧包含文本,因此会填充容器左边缘的任何剩余宽度。

如果我调整(缩小)浏览器的大小,我希望左侧框中的文本是流畅的。好的到目前为止一切顺利...

这是困难的部分: 我需要左侧容器的最小宽度,因此当达到最小宽度时,文本框停止缩小,右侧照片框开始在左侧框下方滑动,直到消失。 这可能吗?

感谢任何帮助!

最佳答案

您可以通过定位实现 z-index 重叠,但不能通过 float 实现。你必须做这样的事情:

http://jsfiddle.net/jphB2/

代码和内联解释:

.leftbox {
    position: relative; /* stay sort of in the document flow */
    z-index: 2; /* be positioned at level 2 */
    min-width: 200px; /* minimum width at which to stop getting smaller */
    margin-right: 200px; /* catering for that right column */
    background-color: rgba(155, 155, 255, 0.8); /* slightly transparent so we can see the right box go 'underneath' it */
}

.rightbox {
    position: absolute; /* remove from the document flow */
    right: 0; /* sit where we want it to */
    top: 0; /* sit where we want it to */
    z-index: 1; /* be positioned at level 1, so below level 2 */
    width: 200px; /* set a width */
    background-color: rgba(255, 155, 155, 0.8); /* uhh, colours are nice */
}

关于css - 并排框 : how to make one slide underneath?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22600706/

相关文章:

html - CSS 内联 block 定位问题

html - 从图像创建HTML/CSS的最佳方法

html - 如何让 SVG 容器拥抱它的内容?

html - 路由在 AngularJS 中不起作用

javascript - 由于 CSS,Codemirror 显示不正确

javascript - 从一个div中提取图像并使用javascript将其插入另一个div

html - 无法更改 Primefaces p :commandButton font properties

html - 搜索框和提交按钮出现无边框

css - Angular Material 表没有响应

Jquery 动画文件树 - 如何将每个 li 高度转换为 auto