我其實就是想當滾動條滾到大于200像素時,然后那個用固定定位的#wei藍色的div向上移動,可這移動方法有問題啊例如用bottom和right設置動畫就沒效果 而且這是相對于整個窗口移動的吧,最重要的一點是我想如果滾動條小于200想讓div恢復原來滾動條小于200的位置怎么辦啊 我這樣貌似沒用.......?<!DOCTYPE html><html><head>? ? <meta charset="utf-8">? ? <title>ad</title>? ? <style type="text/css">? ? ? ? *{margin: 0; padding: 0;}? ? div{background: red; width: 100%; height: 3000px;}? ? ? div#wei{width: 20px;height: 100px; background: blue; position: fixed; top: 500px; left: 100px;} ?? ? </style>? ? <script type="text/javascript" src="http://www.keleyi.com/keleyi/pmedia/jquery-1.9.1.min.js"></script>?? ? ?<script type="text/javascript">? ?? ? ?? ? ?$(function ?() {? ? ? $(window).scroll(function (){? ? ? ? ? ? if ($(window).scrollTop()>200) {? ? ? ? ? ? ? $("#wei").animate({top:'200px'});? ? ? ? ? }? ? ? ? ? else {? ? ? ? ? ?$("#wei").animate({top:'500px'});? ? ? ? ? }? ? ? ? });? ? });? ??? ? </script></head><body>?<div>? <div id="wei"></div>?</div></body></html>
jq我想用animate動畫來實現滾動條到一定距離一個div移動為什么沒用啊
無節操司機
2017-01-17 22:25:10