如何为每个设备将 link 和两张照片居中?

how to center a link with two pics for every device?

我的页面结构如下:

<body>
  <a href="...">
    <img src="..." height="160" width="261">
    <img src="..." height="160" width="160">
  </a>
</body>

提前致谢

     a {
        display: flex;
        width:auto;
     }

您可以通过多种方式实现这一目标。如果你想保持 html 结构不变,那么你可以放置你的锚标记,然后放置 50% 的水平和垂直间距,并将其推回到它自己的高度和宽度。

a{
  position: absolute;
  top: 50%; left: 50%; /* push it to vertically & horizontally */
  transform: translate(-50%, -50%); /* push it back of it's own width & height */
}

View the demo