<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="jquery.js.js"></script>
<script>
$(document).ready(function(){
$('#top').click(function(){
$('#ball').animate({"margin-top":"10px"},800);
})
$('#left').click(function(){
$('#ball').animate({"margin-left":"10px"},800);
})
$('#right').click(function(){
$('#ball').animate({"margin-left":"740px"},800);
})
$('#bottom').click(function(){
$('#ball').animate({"margin-top":"335px"},800);
})
$('#default').click(function(){
$('#ball').css("margin","auto");
$('#ball').css("margin-top","170px");
})
})
</script>
<style>
.container{
width: 100%;
height: 100%;
}
.container .ball-box{
width: 800px;
height: 60vh;
border: 5px dotted;
margin: 0 auto;
margin-top: 30px;
}
.container #ball{
width: 50px;
height: 50px;
border-radius: 50%;
margin: 0 auto;
margin-top: 170px;
background: radial-gradient(rgba(0,0,0,0.3),black);
}
.btn-box{
width: 200px;
height: 20vh;
/* border: 2px dotted; */
margin: 0 auto;
margin-top: 20px;
}
.btn-box #top{
width: 60px;
padding: 5px;
margin-bottom: 10px;
}
.btn-box #left{
width: 60px;
padding: 5px;
float: left;
}
.btn-box #right{
width: 60px;
padding: 5px;
float: right;
}
.btn-box #default{
width: 60px;
padding: 5px;
}
.btn-box #bottom{
width: 60px;
padding: 5px;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="ball-box">
<div id="ball"></div>
</div>
<div class="btn-box">
<center><button id="top">Top</button></center>
<button id="left">Left</button>
<button id="right">Right</button>
<center><button id="default">Default</button></center>
<center><button id="bottom">Bottom</button></center>
</div>
</div>
</body>
</html>
Comments
Post a Comment