I have created a bit of code and I want to make it so I can click the red box and that it will move and stay in that position. Is there a way of doing this? do I need to us JS? I want it to stay at the top and also is there a way to make it so when I just hover over it once then it will move because at the moment when I make it hover, when the mouse is no longer over the div it will just stop the animation. Any input is appreciated :).
This is the code that I currently have (HTML then CSS). please let me know if you have any input or feedback. I am still new to HTML and CSS so some things might be a little sloppy.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css" />
<title>Document</title>
</head>
<body>
<div class="container">
<div class="textbox"></div>
</div>
</body>
</html>
*{
padding: 0;
margin: 0;
}
body{
background-color: rgb(21,21,21);
display: flex;
justify-content: center;
}
.container{
height: 425px;
width: 300px;
border: 2px solid;
border-color: rgb(43, 238, 252);
border-radius: 25px;
display: flex;
align-items: end;
}
.textbox{
width: 300px;
height: 150px;
border: 2px solid;
border-color: rgb(43, 238, 252);
border-bottom-left-radius: 22px;
border-bottom-right-radius: 22px;
border-top-left-radius: 0px;
border-top-left-radius: 0px;
background-color: red;
}
@keyframes texboxMove{
from {border-bottom-left-radius: 22px;}
to {border-bottom-left-radius: 0px;}
from {border-bottom-right-radius: 22px;}
to {border-bottom-right-radius: 0px;}
from {margin-bottom: 0%;}
to {margin-bottom: 90%;}
from {border-top-left-radius: 0px;}
to {border-top-left-radius: 22px;}
from {border-top-right-radius: 0px;}
to {border-top-right-radius: 22px;}
}
.textbox:active{
animation-name: texboxMove;
animation-duration: 2s;
}