I am new to CSS animation and I am trying to create a circle that moves from one end to the other on hover. However, I am facing an issue where the circle goes off-screen when the browser size is changed. How can I make it stop at a certain point within the div? Is there a CSS solution for this or do I need to use Javascript or jQuery in this case?
html, body, #wrapper{
min-width: 1000px;
min-height: 100%;
margin: 0;
padding: 0;
}
#wrapper{
position: relative;
}
body{
padding: 50px;
background-color: #f9f1dc;
}
.one{
background-color: #ffeffd;
padding: 15px;
border-radius: 50px;
width: auto;
}
.ball{
display: inline-block;
height: 100%;
width: 100%;
border-color: none;
border-radius: 100%;
background-color: #662a48;
transition: transform 500ms ease-in-out;
}
.stay{
height: 150px;
width: 150px;
border-radius: 150px;
}
.stay:hover .ball{
transform: translateX(770%);
}
<!DOCTYPE html>
<html>
<head>
<link href="css/ball-animation.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="one">
<div id="wrapper">
<div class="stay">
<div class="ball"></div>
</div>
</div>
</div>
</body>
</html>