51可用代码模板网站

咨询热线:

181-1164-6936
  • 1
CSS样式
当前位置:首页>实用代码>CSS样式>

纯CSS3实现动画不规则的tab标签切换代码

时间:2017-08-15 13:56点击:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>纯CSS3实现的tab标签</title>
<style>
body {
width: 700px;
margin: 100px auto 0 auto;
font-family: Arial, Helvetica;
font-size: small;
background: #444;
}
#tabs {
overflow: hidden;
width: 100%;
margin: 0;
padding: 0;
list-style: none;
}
#tabs li {
float: left;
margin: 0 .5em 0 0;
}
#tabs a {
position: relative;
background: #ddd;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ddd));
background-image: -webkit-linear-gradient(top, #fff, #ddd);
background-image: -moz-linear-gradient(top, #fff, #ddd);
background-image: -ms-linear-gradient(top, #fff, #ddd);
background-image: -o-linear-gradient(top, #fff, #ddd);
background-image: linear-gradient(to bottom, #fff, #ddd);
padding: .7em 3.5em;
float: left;
text-decoration: none;
color: #444;
text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
-webkit-border-radius: 5px 0 0 0;
-moz-border-radius: 5px 0 0 0;
border-radius: 5px 0 0 0;
-moz-box-shadow: 0 2px 2px rgba(0, 0, 0, .4);
-webkit-box-shadow: 0 2px 2px rgba(0, 0, 0, .4);
box-shadow: 0 2px 2px rgba(0, 0, 0, .4);
}
 #tabs a:hover, #tabs a:hover::after, #tabs a:focus, #tabs a:focus::after {
 background: #fff;
}
#tabs a:focus {
outline: 0;
}
 #tabs a::after {
 content:'';
 position:absolute;
 z-index: 1;
 top: 0;
 right: -.5em;
 bottom: 0;
 width: 1em;
 background: #ddd;
 background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ddd));
 background-image: -webkit-linear-gradient(top, #fff, #ddd);
 background-image: -moz-linear-gradient(top, #fff, #ddd);
 background-image: -ms-linear-gradient(top, #fff, #ddd);
 background-image: -o-linear-gradient(top, #fff, #ddd);
 background-image: linear-gradient(to bottom, #fff, #ddd);
 -moz-box-shadow: 2px 2px 2px rgba(0, 0, 0, .4);
 -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, .4);
 box-shadow: 2px 2px 2px rgba(0, 0, 0, .4);
 -webkit-transform: skew(10deg);
 -moz-transform: skew(10deg);
 -ms-transform: skew(10deg);
 -o-transform: skew(10deg);
 transform: skew(10deg);
 -webkit-border-radius: 0 5px 0 0;
 -moz-border-radius: 0 5px 0 0;
 border-radius: 0 5px 0 0;
}
 #tabs #current a, #tabs #current a::after {
 background: #fff;
 z-index: 3;
}
#content {
background: #fff;
padding: 2em;
height: 220px;
position: relative;
z-index: 2;
-moz-border-radius: 0 5px 5px 5px;
-webkit-border-radius: 0 5px 5px 5px;
border-radius: 0 5px 5px 5px;
-moz-box-shadow: 0 -2px 3px -2px rgba(0, 0, 0, .5);
-webkit-box-shadow: 0 -2px 3px -2px rgba(0, 0, 0, .5);
box-shadow: 0 -2px 3px -2px rgba(0, 0, 0, .5);
}
#content h2, #content h3, #content p {
margin: 0 0 15px 0;
}
#about {
color: #999;
}
#about a {
color: #eee;
}
</style>
</head>


<body>
<ul id="tabs">
  <li><a href="/" title="tab1">选项卡1</a></li>
  <li><a href="#" title="tab2">选项卡2</a></li>
  <li><a href="#" title="tab3">选项卡3</a></li>
  <li><a href="#" title="tab4">选项卡4</a></li>
</ul>
<div id="content">
  <div id="tab1">
    <h2>Lorem ipsum sit amet</h2>
    <p>Praesent risus nisi, iaculis nec condimentum vel, rhoncus vel dolor. Aenean nisi lectus, varius nec tempus id, dapibus non quam.</p>
    <p>Suspendisse ac libero mauris. Cras lacinia porttitor urna, vitae molestie libero posuere et</p>
    <h3>Pellentesque habitant</h3>
    <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae.</p>
  </div>
  <div id="tab2">
    <h2>Vivamus fringilla suscipit justo</h2>
    <p>Aenean dui nulla, egestas sit amet auctor vitae, facilisis id odio. Donec dictum gravida feugiat.</p>
    <p>Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos</p>
    <p>Morbi tincidunt pharetra orci commodo molestie. Praesent ut leo nec dolor tempor eleifend.</p>
  </div>
  <div id="tab3">
    <h2>Phasellus non nibh</h2>
    <p>Non erat laoreet ullamcorper. Pellentesque magna metus, feugiat eu elementum sit amet, cursus sed diam.</p>
    <h3>Duis pulvinar nibh vel urna</h3>
    <p>Donec purus leo, porttitor eu molestie quis, porttitor sit amet ipsum</p>
    <p>Suspendisse ac libero mauris. Cras lacinia porttitor urna, vitae molestie libero posuere et. </p>
  </div>
  <div id="tab4">
    <h2>Cum sociis natoque penatibus</h2>
    <p>Magnis dis parturient montes, nascetur ridiculus mus. Nullam ac massa quis nisi porta mollis venenatis sit amet urna.</p>
    <p>Nam ornare vulputate risus, id volutpat elit porttitor non. In consequat nisi vel lectus dapibus sodales.</p>
    <h3>Imperdiet sem interdum nec</h3>
    <p>Mauris rhoncus tincidunt libero quis fringilla.</p>
  </div>
</div>
<br>
<br>
<script src="/ajaxjs/jquery-1.6.2.min.js"></script>
<script>
$(document).ready(function() {
$("#content div").hide();
$("#tabs li:first").attr("id","current"); 
$("#content div:first").fadeIn();
    
    $('#tabs a').click(function(e) {
        e.preventDefault();        
        $("#content div").hide(); 
        $("#tabs li").attr("id","");
        $(this).parent().attr("id","current");
        $('#' + $(this).attr('title')).fadeIn(); 
    });
})();
</script>
</body>
</html> 
51可用模板(代码)网站专为广大站长朋友提供精品模板与代码,同时免费提供网站收录。
本站域名: WWW.51KYDM.COM    联系方式:QQ:182468923    手机:18111646936
本站关键词:网站链接收录网址收录入口网站免费提交收录网站收录提交入口    网站地图
51可用模板
展开