How can I put background image when I hover a link
<html>
<head> </head>
<body>
<a href="#">Insert Bg in this a when hover</a>
</body>
</html>
答案 0 :(得分:1)
您需要将锚标记的显示属性设置为阻止,并为其填充背景高度。
HTML:
<html>
<head> </head>
<body>
<a href="#">Insert Bg in this a when hover</a>
</body>
</html>
CSS:
a{
display : block;
height : 100px;
}
a:hover{
background : url('http://i.giphy.com/xUySTCEXzJdGCeIj3W.gif');
}
答案 1 :(得分:0)
使用css :hover
psudo-class选择器并设置background-image
属性。
a:hover {
background-image : url(img.png);
}
a:hover {
background-image : url(https://placehold.it/100x15);
}
&#13;
<html>
<head> </head>
<body>
<a href="#">Insert Bg in this a when hover</a>
</body>
</html>
&#13;
答案 2 :(得分:0)
试试这个CSS
a:hover {
background: url("http://wallpaper-gallery.net/images/grey-wallpaper-hd/grey-wallpaper-hd-23.jpg");
//Replace the URL with the desired image you want as a Bg
}
<html>
<head> </head>
<body>
<a href="#">Insert Bg in this a when hover</a>
</body>
</html>