gpt4 book ai didi

html - 在鼠标悬停时更改图像边框

转载 作者:太空宇宙 更新时间:2023-11-04 14:25:11 26 4
gpt4 key购买 nike

我有一个问题,我正在处理画廊 php 脚本并需要帮助,我有一张图片,它周围有一个浅灰色边框,如果有鼠标悬停事件,我希望边框变成灰色。我该怎么做?

提前致谢

最佳答案

使用 :hover 伪类。例如:

<html>
<head>
<style>
IMG.HoverBorder {border:5px solid #eee;}
IMG.HoverBorder:hover {border:5px solid #555;}
</style>
</head>
<body>
<img class="HoverBorder" src="test.png" />
</body>
</html>

上面的代码在我可以访问的所有正常浏览器上运行良好。如果您需要 IE 6 支持,请深呼吸并 check this out (感谢@Brian Kim 提醒我有关 IE6 的信息):

<html>
<head>
<style>
a:hover{ background-color:white; }
a:link img, a:visited img{ border:5px solid #eee; }
a:hover img{ border:5px solid #555; }
</style>
</head>
<body>
<a href="#"><img class="HoverBorder" src="03 messed up status log edit IE6.png" /></a>
</body>
</html>

此方法有多种变体——我建议您点击该站点以获取可能更适合您的情况的其他选项。

关于html - 在鼠标悬停时更改图像边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/466449/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com