<!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{
            width100%;
            height100%;
        }
        .container .ball-box{
            width800px;
            height60vh;
            border5px dotted;
            margin0 auto;
            margin-top30px;   
        }
        .container #ball{
            width50px;
            height50px;
            border-radius50%;
            margin0 auto;
            margin-top170px;
            backgroundradial-gradient(rgba(0,0,0,0.3),black);
        }
        .btn-box{
            width200px;
            height20vh;
            /* border: 2px dotted; */
            margin0 auto;
            margin-top20px;
        }
        .btn-box #top{
            width60px;
            padding5px;
            margin-bottom10px;
        }
        .btn-box #left{
            width60px;
            padding5px;
            floatleft;
        }
        .btn-box #right{
            width60px;
            padding5px;
            floatright;
        }
        .btn-box #default{
            width60px;
            padding5px;
        }
        .btn-box #bottom{
            width60px;
            padding5px;
            margin-top10px;
        }
    </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