今天我在我正在编辑的一些软件的顶部添加了一个带有动画 gif 的彩色背景表格。使用适当的 css,我怎样才能让图像始终留在计算机屏幕上,并在手机和平板电脑上居中?下面是我如何拥有当前的 HTML。谢谢! :--)
<table style="width: 100%;">
<tbody>
<tr>
<td style="background-color: #663399;">
<div><img src="Image URL" alt="Animated Gif"></div>
</td>
</tr>
</tbody>
</table>
最佳答案
.img-wraper {
text-align: left;
}
.img-wraper img {
display: inline-block;
}
@media (max-width: 1024px) {
.img-wraper {
text-align: center;
}
}
<table style="width: 100%;">
<tbody>
<tr>
<td style="background-color: #663399;">
<div class="img-wraper"><img src="Image URL" alt="Animated Gif"></div>
</td>
</tr>
</tbody>
</table>
关于image - 顶部标题 Img 留在计算机上 & 中心在手机和平板电脑上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53311970/