css客齐集社区头像显示效果


代码说明:

这段中,定义了一个大的块DIV; 并给了他一个ID; 下边分别有LI,A,SPAN,IMG四个标签; 这样我们就可以在CSS中设置这四个标签来实现我们想要的效果;

<div id="zishu_test">
<ul>
<li><a href="64d'>http://www.zishu.cn/blogview.asp?logID=553"><span>64d / 47 hits</span><img src="pixu/upload/20080607224454669.jpg">pixu</a></li>
...........
以下这段定义了网页的基本内容和链接的样式;

body{ font-size:12px; line-height:1.8; font-family:Verdana, "宋体", Arial,Sans; text-align:center; background:#FFF; color:#666; margin:50px; padding:0; list-style:none; }
a:link,a:visited{color:#000099; text-decoration: underline;}
a:hover,a:active{color:#000;text-decoration: none;}
以下这行定义了列表横向显示,每个LI占14%的宽度;14%是由100%除以7块等于的; 而且LI里边的内容要居中显示; margin:0 auto; 这句是为了实现FIREFOX居中显示的;

#zishu_test li{ float:left; width:14%;text-align:center; margin:0 auto; list-style:none }
以下这行统一定义了一下A标签;边框,宽度,背景等; 其实这时候已经有边框了,只不过和背景色一样;你看不到; 如果你把网页的背景色改一下; 你就会看到效果了;

#zishu_test li a{border-right:1px solid #fff;border-bottom:1px solid #fff; width:100px; height:110px; background:#fff;display:block; padding-top:10px; margin:auto}
以下定义了图片,给图片边上加了留白效果;和边框效果;

#zishu_test li img{ width:75px; height:75px; display:block; text-align:center; margin:auto; background:#FFF; padding:3px; border:1px solid #D8A18B;}
以下这行就是隐藏SPAN标签里的内容;

#zishu_test li span{display:none;}
以下这行就是定义鼠标移上去的效果; 主要是显示SPAN里的内容; 和定义SPAN内容的位置; 注意;这样去定义SPAN的位置会在不同的浏览器中有不同的效果的;所以才有了后边那两行代码;另外注意的是;这里只定义了SPAN;

#zishu_test li a:hover span{ margin-top:-10px;display:block; border-bottom:1px solid #666; border-right:1px solid #666; background:#FA9000; width:100px; color:#FFF; position:absolute; }
以下这两行是为了在不同浏览器中看到的效果一样而写的;主要是为IE6和IE7写的; 有人问为什么不把IMPORTANT写在上一行中? 你试一试再想一想就知道了; 我用这样的办法去改变IE6和IE7;我也不知道怎么样;因为我实在没有想到更好的办法;

* html #zishu_test li a:hover span {margin-left:-8px; } /* IE6 */
*+html #zishu_test li a:hover span {margin-left:-8px; }/* IE7*/
最后这行就简单了;只是改变边框的色,给人的感觉就是鼠标移上去有变化了;

#zishu_test li a:hover{ border-right:1px solid #D8A18B;border-bottom:1px solid #D8A18B; width:100px; height:110px; background:#F5F5F5;display:block; padding-top:10px;}

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3