鼠标移入显示图片案例

一.需要的效果

1).未移入前

2).鼠标移入后

3).鼠标移出

二.实现代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<style>
		a {
			position: relative;
		}
		a img{
			display: none;
			position:absolute;
			left: 50%;
			margin-left: -60px;
			margin-top: -2px;
		}
		a:hover img{
			display: block;
		}
	</style>
	<body>
		<a href="" class="text-muted">
    		<span>宠物之家</span><br />
    		<img src="img/pet_04.jpg"  alt="宠物之家" width="130px"/>
    	</a>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/xm393392625/article/details/82656302