先感谢以下楼上那个大神提供的CSS效果,我第一次用,感觉很不错
但是,看了一下,那个渐变效果毕竟是CSS3的属性,对于较老的浏览器就会失灵,还是用js实现可能更保险些。
CSS文件:
#block{ width:200px; height:300px; overflow:hidden;}
.tab{
color:#FFF;
line-height:60px;
width:100px; height:60px;
background:#000;
margin:10px;
padding-left:5px;
float:right;
position:relative;
left:25px;
-moz-border-radius: 15px; /* Gecko browsers */
-webkit-border-radius: 15px; /* Webkit browsers */
border-radius:15px; /* W3C syntax */
transition:all 0.2s ease-in-out 0;
}
.tab:hover{ width:170px; background:#06F;}
Html文件:
无标题文档 tab1tab2tab3
刚才提到了用js实现效果,这里补充一下
首先把CSS样式中的transition属性和tab的hover俩个都注掉或删掉
如果单纯的只是实现弹出和变色,非常简单
$(".tab").hover(
function(e){
$(this).width(170);
$(this).css("background","#06F");
},
function(e){
$(this).width(100);
$(this).css("background","#000");
}
);
但是如果要渐变效果就要稍微复杂一点了
CSS3就可以的 hover伪类a:hover{width:130px;transition:all 0.2s ease-in-out 0 }