将两个图像水平对齐在一个div中 [英] Centering two images horizontally aligned in a single div

查看:146
本文介绍了将两个图像水平对齐在一个div中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在页面中央水平放置两个图像。我似乎不能得到这个工作,这是我的第四次尝试。
html:

I'm trying to get two images next to each other horizontally and in the centre of the page. I can't seem to get this to work, this is my fourth attempt. html:

<div class="flex_img">
    <div class="left">
        <img src="images/left_image.jpg" width="460" height="300" /> 
    </div>
    <div class="right">
        <img src="images/right_image.jpg" width="460" height="300" />
       </div>
     </div>

css:

.flex_img{align-items: center;}


推荐答案

您可以尝试此流程代码。这是优化的解决方案。

you can try this flow code. This is the optimized solution.

.flex_img{display: flex; justify-content: center;}


<div class="flex_img">
<div class="left"> <img src="images/left_image.jpg" width="460" height=
  "300" /> </div>
<div class="right"> <img src="images/right_image.jpg" width="460"
  height="300" /> </div>
</div>

这篇关于将两个图像水平对齐在一个div中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆