課程
/前端開發
/HTML/CSS
/帝堵搶車位動畫制作
最后效果是飛來飛去的,能添加一個判斷行為、清除行為事件嗎
2016-06-10
源自:帝堵搶車位動畫制作
正在回答
1)將鼠標hover,改成click事件。
<!DOCTYPE html><html lang="en"><head> ? ?<meta charset="UTF-8"> ? ?<title>搶車位動畫效果制作</title> ? ?<script src="jquery-1.11.1.js"></script> ? ?<style> ? ? ? ?.car-box { ? ? ? ? ? ?position: relative; ? ? ? ? ? ?width:720px; ? ? ? ? ? ?height:701px; ? ? ? ?} ? ? ? ?/*.carport{*/ ? ? ? ? ? ?/*width:720px;*/ ? ? ? ? ? ?/*height:701px;*/ ? ? ? ? ? ?/*display: inline-block;*/ ? ? ? ? ? ?/*z-index:2;*/ ? ? ? ?/*}*/ .car{ ? ? ? ? ? ?position: absolute; ? ? ? ? ? ?top:0; ? ? ? ? ? ?left:720px; ? ? ? ?} ? ?</style></head><body><div class="car-box"> ? ?<img class='car' src="car.png"/> ? ?<img class="carport" src="carport.png"/></div><script> ? ?$(document).ready(function(){ ? ? ? ?$(".car").click(function() { ? ? ? ? ? ?var left = $(this).css('left'); ? ? ? ? ? ?if (left == '720px') { ? ? ? ? ? ? ? ?$(".car").animate({left: 0}, {duration: 300}) ? ? ? ? ? ?}else{ ? ? ? ? ? ? ? ?$(".car").animate({left:"720px"}, {duration: 300}) ? ? ? ? ? ?} ? ? ? ?} ? ?) ? ?})</script></body></html>
舉報
帶領大家做一個搶車動畫效果,學會滑動動畫效果,成為搶車位達人
1 回答關于不能顯示特效
1 回答不知道效果怎么不出來
2 回答不能用this?
2 回答為什么click無效果?大家的有效果嗎
3 回答怎么沒有效果
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-06-17
1)將鼠標hover,改成click事件。
<!DOCTYPE html>
<html lang="en">
<head>
? ?<meta charset="UTF-8">
? ?<title>搶車位動畫效果制作</title>
? ?<script src="jquery-1.11.1.js"></script>
? ?<style>
? ? ? ?.car-box {
? ? ? ? ? ?position: relative;
? ? ? ? ? ?width:720px;
? ? ? ? ? ?height:701px;
? ? ? ?}
? ? ? ?/*.carport{*/
? ? ? ? ? ?/*width:720px;*/
? ? ? ? ? ?/*height:701px;*/
? ? ? ? ? ?/*display: inline-block;*/
? ? ? ? ? ?/*z-index:2;*/
? ? ? ?/*}*/
.car{
? ? ? ? ? ?position: absolute;
? ? ? ? ? ?top:0;
? ? ? ? ? ?left:720px;
? ? ? ?}
? ?</style>
</head>
<body>
<div class="car-box">
? ?<img class='car' src="car.png"/>
? ?<img class="carport" src="carport.png"/>
</div>
<script>
? ?$(document).ready(function(){
? ? ? ?$(".car").click(function() {
? ? ? ? ? ?var left = $(this).css('left');
? ? ? ? ? ?if (left == '720px') {
? ? ? ? ? ? ? ?$(".car").animate({left: 0}, {duration: 300})
? ? ? ? ? ?}else{
? ? ? ? ? ? ? ?$(".car").animate({left:"720px"}, {duration: 300})
? ? ? ? ? ?}
? ? ? ?}
? ?)
? ?})
</script>
</body>
</html>