HTML 两张图片并排放置,填充资源管理器窗口的整个宽度

发布于 2025-01-18 13:58:09 字数 274 浏览 3 评论 0 原文

我正在寻找一种解决方案,以并排放置两张图片,并填充Explorer窗口的完整宽度。 这两张照片具有不同的格式(肖像和景观)。然后,同一行中的两张照片都应具有相同的高度。例如,如示例照片所示,但不能如下所示。 有这样的方法吗?

I am looking for a solution to get two pictures side by side positioned, filling out the full width of the explorer window.
The two photos have different formats (portrait and landscape). The two photos in the same row should then both have the same height. For example as in the example photo, but it must not be distorted as shown here.
Is there a way to get it like this?
enter image description here

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

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

发布评论

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

评论(4

仲春光 2025-01-25 13:58:09

图片如下显示:

<a><img src="leftpicture.jpg" alt="">
</a>
<a><img src="rightpicture.jpg" alt="">
</a>

the pictures are displayed like this:

<a><img src="leftpicture.jpg" alt="">
</a>
<a><img src="rightpicture.jpg" alt="">
</a>
小…楫夜泊 2025-01-25 13:58:09
The HTML: 
   `<div class="row">
        <div class="column">
          <img src="image.png" style="width:100%">
        </div>
        <div class="column">
          <img src="image.png" style="width:100%">
        </div>
    </div>`

The css:
`<style>
.row {
  display: flex;
}

.column {
  flex: 50%;
  padding: 5px;
}
</style>

`

The HTML: 
   `<div class="row">
        <div class="column">
          <img src="image.png" style="width:100%">
        </div>
        <div class="column">
          <img src="image.png" style="width:100%">
        </div>
    </div>`

The css:
`<style>
.row {
  display: flex;
}

.column {
  flex: 50%;
  padding: 5px;
}
</style>

`

倒带 2025-01-25 13:58:09

现在它们的宽度相同,但高度不同。为什么???
这是我使用的代码:

html:

    <div class="row">
        <div class="column">
            <a href="Ananasfrucht (1g).JPG" data-lightbox="1-Ananas" data-title="nach ca. 3 Jahren ist der Fruchtansatz erkennbar (nach 1 Woche)">
                <img src="Ananasfrucht (1g).JPG" alt="Ananasfrucht" style="width: 100%">                    
            </a>
        </div>
        <div class="column">
            <a href="Ananasfrucht (2g).JPG" data-lightbox="1-Ananas" data-title="nach ca. 3 Jahren ist der Fruchtansatz erkennbar (nach 1 Woche)">
                <img src="Ananasfrucht (2g).JPG" alt="Ananasfrucht" style="width: 100%">
            </a>
        </div>
    </div>

css:

.row {
  display: flex;
}

.column {
  flex: 50%;
  padding: 5px;
}

在此处输入图像描述

Now they have the same width, but not the same height. Why???
This is the code I use:

html:

    <div class="row">
        <div class="column">
            <a href="Ananasfrucht (1g).JPG" data-lightbox="1-Ananas" data-title="nach ca. 3 Jahren ist der Fruchtansatz erkennbar (nach 1 Woche)">
                <img src="Ananasfrucht (1g).JPG" alt="Ananasfrucht" style="width: 100%">                    
            </a>
        </div>
        <div class="column">
            <a href="Ananasfrucht (2g).JPG" data-lightbox="1-Ananas" data-title="nach ca. 3 Jahren ist der Fruchtansatz erkennbar (nach 1 Woche)">
                <img src="Ananasfrucht (2g).JPG" alt="Ananasfrucht" style="width: 100%">
            </a>
        </div>
    </div>

css:

.row {
  display: flex;
}

.column {
  flex: 50%;
  padding: 5px;
}

enter image description here

终止放荡 2025-01-25 13:58:09

我可以想到两种方法来做到这一点。

第一种方法是创建一个

,并在其中放置两个 标签,然后相应地自定义图像的大小。 查看此 CodePen。(我随机挑选了在 Google 上找到的照片。)

第二种方法是是创建两个 div [在父容器下] 并将所需的图像设置为它们的背景图像。 请参阅其他 CodePen。

我个人更喜欢使用图像标签,以便可以调整图像大小快速并根据需要。在我看来,必须调整大小并避免重复 div 的背景图像会有点压力,但当然这一切都取决于您想要在网站上实现的目标。

There are two ways I can think of to do this.

The first is to create a <div>, and place two <img> tags in it, then customize the sizing of the images accordingly. See this CodePen. (I picked up random photos I found on Google.)

The second way would be to create two divs [under the parent container] and set the desired images as background images for them. See this other CodePen.

I would personally prefer to use image tags so that I can resize the image quickly and as needed. It's a little more stressful to have to adjust the size and avoid repeating of the background image of the div in my opinion, but of course it all depends on what you are trying to achieve on your site.

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