html - Circle animation not centered on center -
i have little problem animation css of circle.
the center of animation not displayed correctly click.
the translation(-50%, -50%) works after animation.
here demo: https://plnkr.co/edit/0umwazgbmixwlu61ee2m
do have idea how deal that?
// code goes here function printmousepos(event) { var element = document.getelementbyid("body"); var para1 = document.createelement("div"); para1.classname = "circle"; para1.setattribute("style", "position : absolute;left:" + event.clientx + "px;top:" + event.clienty + "px"); element.appendchild(para1); var para2 = document.createelement("div"); para2.classname = "point"; para2.setattribute("style", "position : absolute;left:" + event.clientx + "px;top:" + event.clienty + "px"); element.appendchild(para2); console.log(event.clientx, event.clienty); } document.addeventlistener("click", printmousepos); /* styles go here */ body { position: relative; height: 1000px; } @keyframes circle { { transform: scale(0, 0) } { transform: scale(2, 2) } } .circle { color: blue; width: 200px; height: 200px; border-style: solid; border-width: 20px; border-color: blue; border-radius: 50%; transform: translate(-50%, -50%); animation-name: circle; animation-duration: 1s; animation-iteration-count: 3; /*transform-origin: 0 0;*/ } .point { color: red; border-style: solid; border-width: 5px; border-color: red; border-radius: 50%; } <!doctype html> <html> <head> <link rel="stylesheet" href="style.css"> <script src="script.js"></script> </head> <body id="body"> <h1>click everywhere</h1> </body> </html> thanks!
your keyframes callout should this:
@keyframes circle { { transform: scale(0,0) translate(-50%, -50%); } { transform: scale(2,2) translate(-50%, -50%); } }
Comments
Post a Comment