首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >并排框:如何在下面做一张幻灯片?

问并排框:如何在下面做一张幻灯片?
EN

Stack Overflow用户
提问于 2014-03-24 03:42:07
回答 1查看 49关注 0票数 1

想象两个盒子并排在一起。右边的一个是向右浮动的,固定的宽度保持一张照片,左边包含文本,这样就可以将剩余的宽度填充到容器的左边边缘。

如果我调整浏览器的大小(压缩),我希望左边框中的文本保持流畅。到目前为止还不错..。

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

任何帮助都很感激!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-24 05:33:46

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

http://jsfiddle.net/jphB2/

代码和内联解释:

代码语言:javascript
复制
.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 */
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22600706

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档