為什么可以左移,右移卻不行啊,檢查半天沒發現代碼不妥啊。
<script type="text/javascript">
??????? $(function(){
??????????? $("#b1").bind("click",function(){
??????????????? $("h1").html("move left");
??????????????? $("div").animate({
??????????????????? left:"-=50px"
??????????????? },1500,function(){
??????????????????? $("h1").html("finish.");
??????????????? });
???????????????
??????????? });
??????????? $("#b2").bind("click",function(){
??????????????? $("h1").html("move right");
??????????????? $("div").animate({
??????????????????? left:"+=50px"
??????????????? },1500,function(){
??????????????????? $("h1").html("finish.")
??????????????? });
??????????? });
??????? });
??? </script>
2016-07-18
<style type="text/css">
??????????????? .div1{
??????????????????? position:relative;
??????????????? width:100px;
??????????????? height:100px;
??????????????? border: solid 2px black;
??????????????? background-color: purple;
??????????????? color:White;
??????????????? margin:20px auto;
??????????????? margin-left:60px;
??????????????????? }
??????????? </style>??
2016-07-18
我試了一下可以的,div的css是不是有問題?
我的div的css是這樣的
<style type="text/css">
div{
position:absolute;
background-color:red;
width:20px;
height:20px;
left:50%;
right:50%;
}
</style>