|
子鼠相册效果V2.0___DIV+CSS
曾经(大约一年前)用CSS作了一个相册的效果。
链接如下:http://www.zishu.cn/blogview.asp?logID=459
上边的效果是鼠标经过时才会显示大图,但是看起来不是很方便,也不合用户浏览习惯,但那时能作到的效果只能那样了,没有想出更好的办法。
昨天,我在弄《IE中锚点失效的解决办法 》时突然想到了这个相册的效果。想到了利用锚点还可以改进。
于是,就有了下边的效果:
CSS代码如下:
lt;style><br />
body{ margin:0; padding:0; font-size:12px; background: #333333; line-height:1.7; font-family:Verdana, quot;宋体"; overflow:hidden }<br />
#info{ width:600px; background: #666666; margin-left:auto; margin-right:auto; text-align:center; border:1px solid #FFFFFF; height:400px; margin-top:20px;}<br />
h3{ margin:20px 0 0 0; color:#CC0000; font-size:12px;color:#FFF}<br />
ul,li{ list-style:none; margin:0; padding:0;}<br />
a:active,a:hover{ cursor:pointer}<br />
#info #zs img{ width:400px; height:280px; border:7px solid #FFF;}<br />
#zs{ height:360px; overflow: hidden; text-align:left; float:left; width:450px; margin-top:20px}<br />
#zs ul{ margin:0 0 0 30px;}<br />
#zs span{ display:block}<br />
#zs a{ display:inline}<br />
#nav{ padding-right:10px;width:135px; height:350px; overflow:auto; padding:0; text-align:left; float:left;}<br />
#nav a{ display:block}<br />
.z{ width:80px; height:56px;display:block; border:1px solid #FFFFFF; margin:4px 0 4px 25px;color:#FFF}<br />
.b1{ background:url(http://www.zishu.cn/images/b1.jpg)}<br />
.b2{ background:url(http://www.zishu.cn/images/b2.jpg)}<br />
.b3{ background:url(http://www.zishu.cn/images/b3.jpg)}<br />
.b4{ background:url(http://www.zishu.cn/images/b4.jpg)}<br />
.b5{ background:url(http://www.zishu.cn/images/b5.jpg)}<br />
.b6{ background:url(http://www.zishu.cn/images/b6.jpg)}<br />
#zs li{ display:block; height:400px;}<br />
lt;/style>
复制代码
BODY部分:
lt;div id="info"><br />
nbsp; <h3>子鼠的CSS相册v2.0</h3><br />
nbsp; <div id="zs"> <br />
nbsp; <ul><br />
nbsp; <li><a name="z1" id="z1"></a><img src="http://www.zishu.cn/images/a1.jpg" alt="照片1" /><br /><br />
nbsp; 这是照片1<br />
nbsp; <span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
nbsp; <li><a name="z2" id="z2"></a><img src="http://www.zishu.cn/images/a2.jpg" alt="照片2" /><br /><br />
nbsp; 这是照片2<br />
nbsp; <span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
nbsp; <li><a name="z3" id="z3"></a><img src="http://www.zishu.cn/images/a3.jpg" alt="照片3" /><br /><br />
nbsp; 这是照片3<br />
nbsp; <span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
nbsp; <li><a name="z4" id="z4"></a><img src="http://www.zishu.cn/images/a4.jpg" alt="照片4" /><br /><br />
nbsp; 这是照片4<br />
nbsp; <span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
nbsp; <li><a name="z5" id="z5"></a><img src="http://www.zishu.cn/images/a5.jpg" alt="照片5" /><br /><br />
nbsp; 这是照片5<br />
nbsp; <span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
nbsp; <li><a name="z6" id="z6"></a><img src="http://www.zishu.cn/images/a6.jpg" alt="照片6" /><br /><br />
nbsp; 这是照片6<br />
nbsp; <span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
nbsp; <li><a name="z7" id="z7"></a><img src="http://www.zishu.cn/images/a1.jpg" alt="照片1" /><br /><br />
nbsp; 这是照片1<br />
nbsp; <span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
nbsp; <li><a name="z8" id="z8"></a><img src="http://www.zishu.cn/images/a2.jpg" alt="照片2" /><br /><br />
nbsp; 这是照片2<br />
nbsp; <span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
nbsp; </ul><br />
nbsp; </div><br />
nbsp; <br />
nbsp; <div id="nav"><br />
nbsp; <a href="#z1" class="b1 z" title="照片1"></a><br />
nbsp; <a href="#z2" class="b2 z" title="照片2"></a><br />
nbsp; <a href="#z3" class="b3 z" title="照片3"></a><br />
nbsp; <a href="#z4" class="b4 z" title="照片4"></a><br />
nbsp; <a href="#z5" class="b5 z" title="照片5"></a><br />
nbsp; <a href="#z6" class="b6 z" title="照片6"></a><br />
nbsp; <a href="#z7" class="b1 z" title="照片1"></a><br />
nbsp; <a href="#z8" class="b2 z" title="照片2"></a><br />
nbsp; </div><br />
lt;/div>
复制代码
效果如下:
<!DOCTYPE <span href="tag.php?name=html" onclick="tagshow(event)" class="t_tag">html</span> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
<title>子鼠的CSS相册v2.0</title><br />
<style><br />
body{ margin:0; padding:0; font-size:12px; background: #333333; line-height:1.7; font-family:Verdana, "宋体"; overflow:hidden }<br />
#info{ width:600px; background: #666666; margin-left:auto; margin-right:auto; text-align:center; border:1px solid #FFFFFF; height:400px; margin-top:20px;}<br />
h3{ margin:20px 0 0 0; color:#CC0000; font-size:12px;color:#FFF}<br />
ul,li{ list-style:none; margin:0; padding:0;}<br />
a:active,a:hover{ cursor:pointer}<br />
#info #zs img{ width:400px; height:280px; border:7px solid #FFF;}<br />
#zs{ height:360px; overflow: hidden; text-align:left; float:left; width:450px; margin-top:20px}<br />
#zs ul{ margin:0 0 0 30px;}<br />
#zs span{ display:block}<br />
#zs a{ display:inline}<br />
#nav{ padding-right:10px;width:135px; height:350px; overflow:auto; padding:0; text-align:left; float:left;}<br />
#nav a{ display:block}<br />
.z{ width:80px; height:56px;display:block; border:1px solid #FFFFFF; margin:4px 0 4px 25px;color:#FFF}<br />
.b1{ background:url(http://www.zishu.cn/images/b1.jpg)}<br />
.b2{ background:url(http://www.zishu.cn/images/b2.jpg)}<br />
.b3{ background:url(http://www.zishu.cn/images/b3.jpg)}<br />
.b4{ background:url(http://www.zishu.cn/images/b4.jpg)}<br />
.b5{ background:url(http://www.zishu.cn/images/b5.jpg)}<br />
.b6{ background:url(http://www.zishu.cn/images/b6.jpg)}<br />
#zs li{ display:block; height:400px;}<br />
</style><br />
</head><br />
<body><br />
<div id="info"><br />
<h3>子鼠的CSS相册v2.0</h3><br />
<div id="zs"><br />
<br />
<ul><br />
<li><a name="z1" id="z1"></a><img src="http://www.zishu.cn/images/a1.jpg" alt="照片1" /><br /><br />
这是照片1<br />
<span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
<li><a name="z2" id="z2"></a><img src="http://www.zishu.cn/images/a2.jpg" alt="照片2" /><br /><br />
这是照片2<br />
<span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
<li><a name="z3" id="z3"></a><img src="http://www.zishu.cn/images/a3.jpg" alt="照片3" /><br /><br />
这是照片3<br />
<span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
<li><a name="z4" id="z4"></a><img src="http://www.zishu.cn/images/a4.jpg" alt="照片4" /><br /><br />
这是照片4<br />
<span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
<li><a name="z5" id="z5"></a><img src="http://www.zishu.cn/images/a5.jpg" alt="照片5" /><br /><br />
这是照片5<br />
<span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
<li><a name="z6" id="z6"></a><img src="http://www.zishu.cn/images/a6.jpg" alt="照片6" /><br /><br />
这是照片6<br />
<span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
<li><a name="z7" id="z7"></a><img src="http://www.zishu.cn/images/a1.jpg" alt="照片1" /><br /><br />
这是照片1<br />
<span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
<li><a name="z8" id="z8"></a><img src="http://www.zishu.cn/images/a2.jpg" alt="照片2" /><br /><br />
这是照片2<br />
<span><a href="http://www.zishu.cn" target="_blank">www.zishu.cn</a></span></li><br />
</ul><br />
</div><br />
<br />
<div id="nav"><br />
<a href="#z1" class="b1 z" title="照片1"></a><br />
<a href="#z2" class="b2 z" title="照片2"></a><br />
<a href="#z3" class="b3 z" title="照片3"></a><br />
<a href="#z4" class="b4 z" title="照片4"></a><br />
<a href="#z5" class="b5 z" title="照片5"></a><br />
<a href="#z6" class="b6 z" title="照片6"></a><br />
<a href="#z7" class="b1 z" title="照片1"></a><br />
<a href="#z8" class="b2 z" title="照片2"></a><br />
</div><br />
</div><br />
</body><br />
</html>
提示:您可以先修改部分代码再运行
这个效果我在IE6和7中测试过了.
另外,由于这个例子中的代码是我从上一个相册中改的,所以代码和CSS不是最优的。有相当大的优化空间。
再另外,在现实中,我想也不会有人用这个东西来作相册,我想实现的只是CSS和HTML在一起到底能作什么。 玩呗! 挑战无处不在!
原贴:http://www.zishu.cn/blogview.asp?logID=599 |
|