我想让一个 div 从它的当前位置向右移动(left: 1000px
)使用过渡?我该如何做到这一点并使用 Javascript 触发它?
最佳答案
检查以下 fiddle
JS
$(document).ready(function(){
$("button").click(function(){
$("div").animate({left: '250px'});
});
});
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div>
关于javascript - 如何使用过渡将 div 从当前位置向右移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50514466/