首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"overflow-x: auto“不会向左滚动

"overflow-x: auto“不会向左滚动
EN

Stack Overflow用户
提问于 2021-04-25 21:33:44
回答 1查看 18关注 0票数 0

我有以下代码:

代码语言:javascript
复制
#container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 22px;
  gap: 22px;
  overflow-x: auto;
}
代码语言:javascript
复制
<div id="container">
  <image src="https://www.perpetuum.eu/sites/perpetuum.eu/files/inline-images/grid-line.jpg" width="888" />
  <div>This image has a fixed width (and thus also its height). This image will not change as a function of the window size. In a mobile it may overflow.</div>
</div>

当有溢出时,图像被保持在中心(这就是我想要的)。但是滚动条只会向右移动,所以看不到左边的部分。如何获得两个方向的滚动?否则,当存在溢出时,我如何才能将对齐方式更改为左对齐?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-25 22:17:32

你不能两个方向都滚动。但是你可以在你的图片中添加一个页边距,溢出效果就会如你所愿。

代码语言:javascript
复制
img {
   margin: 0 auto;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67253973

复制
相关文章

相似问题

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