翻书效果

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
</head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<style>
  html,body,div,ul,li,p,span {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  html,body {
    height: 100%
  }
  body{
    background-color: #999;
    padding:8px;
  }
  ul{list-style: none;}
  #books{
    display: block;
    width:980px;
    height:100%;
    margin:auto;
    position: relative;
    counter-reset:page;
  }
  #books li{
    position: absolute;
    top:0;
    width: 50%;
    height: 100%;
    background-color: #fff;
    transition-duration: 0.5s;
    transition-property: transform,opacity;
    transform-style: preserve-3d;
    box-shadow:0px 0px 12px #000;
  }

  #books li:nth-child(odd){
    left:50%;
    transform:rotateY(0deg);
    transform-origin:0 50% 0;
    opacity: 1;
  }
  #books li:nth-child(even){
    left:0;
    background: linear-gradient(90deg, #fff 92%, #eee 99%, #ccc 100%);
    transform:rotateY(180deg);
    transform-origin:100% 50% 0;
    opacity: 0;
  }
  #books li.rl:nth-child(odd){
    transform:rotateY(180deg);
    opacity: 0;
  }
  #books li.rl:nth-child(even){
    transform:rotateY(0deg);
    opacity: 1;
  }
  #books li:nth-child(odd)::before{
    right:0;
  }
  #books li:nth-child(even)::before{
    left:0;
  }
  #books li:before{
    content: counter(page);
    counter-increment: page;
    position: absolute;
    font:12px/1em "宋体";
    padding: 18px;
    bottom:0;
  }
  #books li:after{
    content:"";
    bottom:0;
    position: absolute;
    width:0;
    height:0;
    box-shadow:-1px -1px 12px #e0e0e0;
    transition-duration: 0.3s;
    transition-property: width,height;
  }
  #books li:nth-child(odd)::after{
    right:0;
    background: linear-gradient(-45deg, transparent 50%, #eee 50%, #fff 90%);
  }
  #books li:nth-child(even)::after{
    left:0;
    background: linear-gradient(45deg, transparent 50%, #eee 50%, #fff 90%);
  }
  #books li:hover::after{
    width:30px;
    height:30px;
  }
</style>
<body>

<ul id="books">
  <li><p style="font-size: 300px; text-align: center;">1</p></li>
  <li><p style="font-size: 300px; text-align: center;">2</p></li>
  <li><p style="font-size: 300px; text-align: center;">3</p></li>
  <li><p style="font-size: 300px; text-align: center;">4</p></li>
  <li><p style="font-size: 300px; text-align: center;">5</p></li>
  <li><p style="font-size: 300px; text-align: center;">6</p></li>
  <li><p style="font-size: 300px; text-align: center;">7</p></li>
  <li><p style="font-size: 300px; text-align: center;">8</p></li>
  <li><p style="font-size: 300px; text-align: center;">9</p></li>
  <li><p style="font-size: 300px; text-align: center;">10</p></li>
  <li><p style="font-size: 300px; text-align: center;">11</p></li>
  <li><p style="font-size: 300px; text-align: center;">12</p></li>
</ul>
<script type="text/javascript">
  $(function(){
    var page = $("#books li").length;
  $("#books li").each(function(index,item){
    $(this).css("z-index", page - index);
  });
  $("#books li:even").click(function(e){
    $(this).add($(this).next()).addClass("rl");
    var obj = this;
  setTimeout(function(){
    $(obj).add($(obj).next()).css("z-index","auto");
  },500)
  })
  $("#books li:odd").click(function(e){
    $(this).prev().css("z-index",page-$(this).index()+1);
    $(this).css("z-index",page-$(this).index());
    $(this).add($(this).prev()).removeClass("rl");
  })
  });
</script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值