js拖动板块滑动js特效
1、新建html文档。
2、书写hmtl代码。 <div class="pep x">X</div> <div class="pep y">Y</div> <div class="pep x trans">X translation</div> <div class="pep y trans">Y translation</div> <div class="pep noease">Y </br> ease disabled</div>
3、书写css代码。 <style type="text/css"> 芟鲠阻缒body{ padding: 0; margin: 0; } .pep { width: 100px; height: 100px; background: rgb(243, 200, 200); color: white; opacity: 0.8;} .x { position: absolute; top: 40px; left: 10px; background: rgb(120, 200, 200); opacity: 0.8;} .y { position: absolute; top: 60px; left: 30px; background: rgb(243, 120, 200); opacity: 0.8;} .noease { position: absolute; top: 80px; left: 50px; background: rgb(243, 80, 100); opacity: 0.8;} </style>
4、书写并添加js代码。 <script src="../libs/jquery/jquery.js"></script> 媪青怍牙<script src="../libs/modernizr.min.js"></script> <script src="../src/jquery.pep.js"></script> <script> $(document).ready(function(){ $('.pep.x').pep({ axis: 'x', debug: true, useCSSTranslation: false }); $('.pep.y').pep({ axis: 'y', debug: true, useCSSTranslation: false }); $('.pep.x.trans').pep({ axis: 'x', debug: true, useCSSTranslation: true }); $('.pep.y.trans').pep({ axis: 'y', debug: true, useCSSTranslation: true }); $('.pep.noease').pep({ axis: 'y', shouldEase: false, debug: true }); }); </script>
5、代码整体结构。
6、查看效果。