首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何创建水平滚动条来查看图像的其余部分?

问如何创建水平滚动条来查看图像的其余部分?
EN

Stack Overflow用户
提问于 2021-05-09 12:09:16
回答 1查看 28关注 0票数 1

<img src="the fake.png" width="3268" height="538" class="table" alt=""/>

这是我的图片的代码,问题是图片对页面来说太大了,而且被剪掉了。我想要一个水平滚动条。我想知道做一个水平滚动条的代码是什么,这样我就可以看到图像的其余部分。我不想调整图像的大小,只是为了能够水平滚动。我知道一个奇怪的想法。如有任何帮助,我们将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-09 12:22:14

可以这样做的一种方法是将图像放在给定尺寸的div中,然后将div上的overflow属性设置为滚动。它看起来像这样:

HTML:

代码语言:javascript
复制
<div class="img-container">
  <img src="the fake.png" width="3268" height="538" class="table" alt=""/>
</div>

CSS:

代码语言:javascript
复制
.img-container{
width: 500px; /*width of the container the image is in, your choice*/
height: auto; /*means the height of the container is the same as the image so you are not scrolling vertically*/
overflow-x: scroll; /*this is the important line that tells the browser to scroll content outside the div*/
}

希望这能有所帮助。另外,我建议使用CSS而不是HTML来设置图像的高度和宽度

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67454215

复制
相关文章

相似问题

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