你的位置:首页 > 网页设计

[网页设计]CSS实现鼠标放图片上显示白色边框+文字描述


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>鼠标悬停时显示图片边框和文字描述的图片特效</title>
<style type="text/css">
body{margin: 0;padding: 0;font: normal 10px Verdana, Arial, Helvetica, sans-serif;line-height: 1.8em;background: #1d1d1d url(bg.jpg) repeat;}
a{color:#999;}
h1{font-family:Georgia, "Times New Roman", Times, serif;text-align: center;font-weight: normal;font-size: 4em;line-height: 1.2em;margin: 0; padding: 20px 0;color:#999;font-size:18px;}
img{border: none;}
ul.gnineh{width: 960px;list-style: none;margin: 0 auto; padding: 0;}
ul.gnineh li{width: 220px;float: left; display: inline;margin: 10px; padding: 0;position: relative;}
ul.gnineh li:hover{z-index: 99;}
ul.gnineh li img{position: relative;filter: alpha(opacity=30);opacity: 0.3;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";}
ul.gnineh li:hover img{z-index: 999;filter: alpha(opacity=100);opacity: 1;-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";}
ul.gnineh li .info{position: absolute;left: -10px; top: -10px;padding: 210px 10px 20px;width: 220px;display: none;background: #fff;font-size: 1.2em;-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px;}
ul.gnineh li:hover .info{display: block;}
ul.gnineh li h2{font-size: 1.2em;font-weight: normal;text-transform: uppercase;margin: 0; padding: 10px 0;}
ul.gnineh li p{padding: 0; margin: 0; font-size: 0.9em;}
body{font-size:12px;font-family:'Arial';line-height:25px;}
#header{background:#000;height:30px;line-height:30px;margin-bottom:20px;}
#header h2{float:left;margin:0px 10px;}
#header h2 a{color:#fff;}
#main{width:950px;margin:0px auto}
.code{border:#ccc 1px solid;background:#ffffcc;padding:10px;}
</style>
</head>
<body>
<div>http://www.999jiujiu.com/</div>
<h1>纯CSS实现的鼠标触及显示边框和描述的图片特效</h1>
<ul >
<li><a href="http://www.cnblogs.com//"><img src="wall_s3.jpg" alt=""></a><div ><h2>美丽荃银高科</h2><p>新车上市堪比波音。</p></div></li>
<li><a href="http://www.cnblogs.com//"><img src="wall_s4.jpg" alt=""></a><div ><h2>我的小狗</h2><p>很可爱的猩猩</p></div></li>
<li><a href="http://www.cnblogs.com//"><img src="wall_s5.jpg" alt=""></a><div ><h2>穿过市区</h2><p>是郊外的清凉</p></div></li>
<li><a href="http://www.cnblogs.com//"><img src="wall_s6.jpg" alt=""></a><div ><h2>梦中情人</h2><p>回首一眸万物俱焚</p></div></li>
</ul>
</body>
</html>