开发者社区> 问答> 正文

jquery的.css设置怎么产生渐变?

我设置了一句 nav.css("opacity","1"); 让变量nav的opacity从0变成1.

请问高手这句怎么写能产生动画效果???

展开
收起
a123456678 2016-07-13 10:24:56 1810 0
1 条回答
写回答
取消 提交回答
  • <div id="clickme"> 
    Click here
    </div> 
    <img id="book" src="book.png" alt="" width="100" height="123"> 
    // With the element initially hidden, we can show it slowly:
    $( "#clickme" ).click(function() {
    $( "#book" ).fadeIn( "slow", function() {
    // Animation complete
    });
    });
    Example 2
    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>fadeIn demo</title>
      <style>
      span {
        color: red;
        cursor: pointer;
      }
      div {
        margin: 3px;
        width: 80px;
        display: none;
        height: 80px;
        float: left;
      }
      #one {
        background: #f00;
      }
      #two {
        background: #0f0;
      }
      #three {
        background: #00f;
      }
      </style>
      <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>
      
    <span>Click here...</span>
    <div id="one"></div>
    <div id="two"></div>
    <div id="three"></div>
      
    <script>
    $( document.body ).click(function() {
      $( "div:hidden:first" ).fadeIn( "slow" );
    });
    </script>
      
    </body>
    </html>
    2019-07-17 19:55:23
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
零基础CSS入门教程 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载