gpt4 book ai didi

CSS 显示 : table-cell width 100% overflow-x expand

转载 作者:行者123 更新时间:2023-11-28 16:42:19 24 4
gpt4 key购买 nike

我有这个两列布局,由 display: table 和 display: table-cell 组成,我想在第二列中放置一个带有水平滚动的 div,但表格会自行扩展并且滚动会转到整个页面而不是 div。

HTML

<div class="wrapper">
<div id="one"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque convallis finibus metus. Suspendisse commodo rutrum sapien, eu faucibus metus. Nunc elementum augue eu aliquet condimentum.
</div>
<div id="two">
<div id="horizontal">
<img src="https://dl.dropbox.com/u/1218282/slideshow/1.jpg" />
<img src="https://dl.dropbox.com/u/1218282/slideshow/2.jpg" />
<img src="https://dl.dropbox.com/u/1218282/slideshow/3.jpg" />
<img src="https://dl.dropbox.com/u/1218282/slideshow/4.jpg" />
</div>
</div>
</div>

CSS

.wrapper { 
display: table;
table-layout: fixed;
}
#one {
display: table-cell;
background-color: gray;
width: 200px;
}
#two {
display: table-cell;
width: 100%;
}
#horizontal {
width: 100%;
overflow-x: scroll;
white-space: nowrap;
}
#horizontal img {
max-width: 200px;
}

这是 jsfiddle: http://jsfiddle.net/cUCvY/2597/

在这个例子中,我想让水平滚动在 div 上处于事件状态,图像在里面而不是在页面上。

最佳答案

希望我理解正确:

.wrapper { 
display: table;
table-layout: fixed;
width:100%
}
#one {
display: table-cell;
background-color: gray;
width: 200px;
}
#two {
}
#horizontal {

overflow-x: scroll;
white-space: nowrap;
}
#horizontal img {
max-width: 200px;
}
}

@media screen and (max-width: 400px) {
#one {
float: none;
margin-right:0;
width:auto;
border:0;
border-bottom:2px solid #000;
}
}

http://jsfiddle.net/cUCvY/2600/

关于CSS 显示 : table-cell width 100% overflow-x expand,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33543894/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com