HTML img align =“中间”;不对齐图像 [英] HTML img align="middle" doesn't align an image

查看:126
本文介绍了HTML img align =“中间”;不对齐图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望图像居中对齐。图像大小以像素为单位固定。

I want a image to be centered aligned. Image size is fixed in pixels.

所以我想要的是这样的

So what I want is like this-

我所做的是-

        <!DOCTYPE html>
<html>
<body>

    <img
        src="http://icons.iconarchive.com/icons/rokey/popo-emotions/128/big-smile-icon.png"
        width="42" height="42"
        align="middle"
        style="float: left;
          position: relative;
          display: block;
          margin-left: auto;
          margin-right: auto;
          z-index: 1;"
        >

</body>
</html>

但是我正在得到-

< img src = https://i.stack.imgur.com/VDkkg.jpg alt = 22>

我希望它具有响应能力。

I want it to be responsive.

有人可以帮助我吗?

推荐答案

这个怎么样?我经常使用CSS灵活框布局将内容居中。

How about this? I frequently use the CSS Flexible Box Layout to center something.

<div style="display: flex; justify-content: center;">
  <img src="http://icons.iconarchive.com/icons/rokey/popo-emotions/128/big-smile-icon.png" style="width: 40px; height: 40px;" />
</div>

这篇关于HTML img align =“中间”;不对齐图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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