[英]How to prevent the table and image elements from moving when resizing browser window
I'm a beginner at coding so I have no idea how to fix the code. 我是编码的初学者,所以我不知道如何修复代码。 I tried looking up solutions but only for div elements appear. 我尝试查找解决方案,但只显示div元素。 I did try them though but still couldn't fix it. 虽然我确实尝试过,但仍然无法解决。
.image { width: 200px; height: 260px; } table { margin-left: auto; margin-right: auto; } td { padding: 10px; } .group { margin-left: auto; margin-right: auto; }
<table> <tr> <td><a href="#" target="_blank"><img src= "#" alt="#" class="image" /> </a></td> <td><a href="#" target="_blank"><img src= "#" alt="#" class="image" /> </a></td> <td><a href="# target="_blank"><img src= "#" alt="#" class="image" /> </a></td> </tr> </table>
You need to add a width
to .table
. 您需要为.table
添加width
。 This will give it a precise width which it can use. 这将赋予它可以使用的精确宽度。
Keep in mind though that this wouldn't make your website responsive on some devices. 请记住,虽然这不会使您的网站在某些设备上响应。
.image { width: 200px; height: 260px; } table { margin-left: auto; margin-right: auto; width: 650px; } td { padding: 10px; } .group { margin-left: auto; margin-right: auto; }
<table> <tr> <td><a href="#" target="_blank"><img src= "#" alt="#" class="image" /> </a></td> <td><a href="#" target="_blank"><img src= "#" alt="#" class="image" /> </a></td> <td><a href="# target="_blank"><img src= "#" alt="#" class="image" /> </a></td> </tr> </table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.