实例代码:
<!doctype html>
<html>
<head>
<meta char="utf-8">
<style>
.dropdown img{
width:60px;
height:50px;
}
.dropdown{
position:relative; /*相对定位*/
display:inline-block; /*显示为内联块*/
}
.dropdown-content {
display:none; /*不显示div*/
position:absolute; /*绝对定位*/
min-width:180px;
background-color:red;
box-shadow:10px 10px 12px 0px #66ccff;
z-index:1; /*设置堆叠层*/
}
.dropdown-content img{
width:192px;
height:150px;
}
.desc{
text-align:center;
padding:15px;
width:160px;
}
.dropdown:hover .dropdown-content{
display:block; /*显示块*/
}
</style>
</head>
<body>
<h1>下拉图片</h1>
<p>请把鼠标移动到图像上,以打开下拉内容</p>
<div class="dropdown">
<img src="img/html5.jpeg" alt="html5"></img>
<div class="dropdown-content">
<img src="img/html5.jpeg" alt="html5"></img>
<div class="desc">HTML5</div>
</div>
</div>
</body>
</html>
运行效果:
评论