css鼠标悬浮小图弹出大图效果

快乐打工仔 分类:实例代码

本章节分享一段代码实例,它实现了鼠标悬浮小图弹出大图效果。

非常的简单,代码如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<title>犀牛前端部落</title>
<style type="text/css">
* {
  margin: 0;
  padding: 0;
}
a {
  text-decoration: none;
}
body {
  width: 620px;
  margin: 0 auto;
  text-align: center;
  padding-top: 30px;
}
ul {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed #c8c8c8;
}
li {
  display: inline-block;
  position: relative;
  list-style: none;
  border: 1px solid #ccc;
  border-color: #ddd #bbb #aaa #ccc;
}
a > img:first-child {
  width: 105px;
  height: 80px;
  padding: 2px;
  border: 5px solid #ddd;
}
.previewImg {
  display: none;
  position: absolute;
  background-color: #ddd;
  width: 200px;
  height: 150px;
  top: -25px;
  left: -43px;
  z-index: 10;
}
a:hover .previewImg {
  display: block;
  border: 1px solid #333;
  padding: 2px;
}
</style>
</head>
<body>
<ul>
  <li>
    <a href="#">
      <img src="demo/CSS/img/photo01.jpg" alt="犀牛前端部落" />
      <img src="demo/CSS/img/photo01.jpg" alt="pipipi.net" class="previewImg" />
    </a>
  </li>
</ul>
</body>
</html>

回复

我来回复
  • 暂无回复内容