CSS中的非背景响应式图像

发布于 2025-01-25 08:49:41 字数 701 浏览 2 评论 0原文

我的图像正在占据其整个维度 - 跨越页面到您必须向右滚动以查看图像的点。我不想要这个。

Web浏览器视图的屏幕截图

我希望我的图像在网页中整齐地拟合并响应并响应页面的大小,无需向右滚动。

我计划在页面上有多个图像,顶部有文本,例如...

多个图像/a>

这是我当前的代码。我一直在尝试不同的替代方案,但我似乎无法弄清楚。

我的CSS代码:

#carousel {
  position: absolute;
}

我的HTML代码:

<div id="carousel" align="center">
        <img src="../images/....jpg" />
</div>

预先感谢。

My images are taking on its entire dimensions-- spanning the page to the point where you have to scroll right to see the image. I do not want this.

Screenshot Of Web Browser View

I would like for my images to neatly fit within the webpage and respond to the size of the page, without scrolling to the right.

I plan to have multiple images on the page with text at the top, like so...

multiple images idea

Here is my current code. I've been trying different alternatives, but I can't seem to figure it out.

My CSS code:

#carousel {
  position: absolute;
}

My HTML code:

<div id="carousel" align="center">
        <img src="../images/....jpg" />
</div>

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆伤 2025-02-01 08:49:41

添加#carousel img {width:100%}#carousel img {object-fit:cover} to css以获取响应式图像。

Add either #carousel img { width: 100% } or #carousel img { object-fit: cover } to your CSS for responsive images.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文