HTML/CSS图像悬停-使用不同大小的图像

HTML/CSS image hover - using different sized images

本文关键字:图像 CSS 悬停 HTML      更新时间:2023-09-26

所以我有这个网站:http://www.gameplay-universe.uphero.com/如果您将鼠标悬停在表中页脚上的社交图像上,您会看到较小的图像变大并移动布局。如何避免/解决此问题?不管是CSS/HTML/JS,我只需要解决这个问题。我的代码:

<table class="social" align="center" height="40" width="40">
<tr>
<td style="white-space: nowrap; margin: 0 auto;">
<a class="myButtonLink" href="#later_to_add">
<img src="/resources-backups/rss-inactive.png" border="0" onmouseover="this.src='/resources-backups/rss-active.png';" onmouseout="this.src='/resources-backups/rss-inactive.png';" alt="rss-feeds" />
</a>
</td>
<td style="white-space: nowrap; margin: 0 auto;">
<a class="myButtonLink" href="#later_to_add">
<img src="/resources-backups/youtube-inactive.png" border="0" onmouseover="this.src='/resources-backups/youtube-active.png';" onmouseout="this.src='/resources-backups/youtube-inactive.png';" alt="youtube" />
</a>
</td>
<td style="white-space: nowrap; margin: 0 auto;">
<a class="myButtonLink" href="#later_to_add">
<img src="/resources-backups/twitter-inactive.png" border="0" onmouseover="this.src='/resources-backups/twitter-active.png';" onmouseout="this.src='/resources-backups/twitter-inactive.png';" alt="twitter" />
</a>
</td>
<td style="white-space: nowrap; margin: 0 auto;">
<a class="myButtonLink" href="#later_to_add">
<img src="/resources-backups/facebook-inactive.png" border="0" onmouseover="this.src='/resources-backups/facebook-active.png';" onmouseout="this.src='/resources-backups/facebook-inactive.png';" alt="facebook" />
</a>
</td>
<td style="white-space: nowrap; margin: 0 auto;">
<a class="myButtonLink" href="#later_to_add">
<img src="/resources-backups/google-plus-inactive.png" border="0" onmouseover="this.src='/resources-backups/google-plus-active.png';" onmouseout="this.src='/resources-backups/google-plus-inactive.png';" alt="google-plus" />
</a>
</tr>
</table>

此外,我还可以摆弄一下更改为新标准的代码(HTML5、CSS3等)。提前感谢!

将这些css属性设置为包含Images:的元素

Position:relative;
height:(Here put in pixels the height of your element)px;

设置一个高度将迫使它保持静止到该高度。

给您的表一个min-height:

更改此行:

<table class="social" align="center" height="40" width="40">

收件人:

<table style="min-height:64px;" class="social" align="center" height="40" width="40" >

我只需要在图像上添加填充或边距,然后在悬停上删除填充/边距

z-index赋予包含图像的<div>