+ 3

Does anyone know how to move an image with css

please write the code in answer

5th Mar 2017, 3:23 PM
VishalYumnam
VishalYumnam - avatar
2 Answers
+ 2
You could use img:hover { transform: translate(100px, 200px) } or img { transition: left 2s; transition: top 2s; } img:hover { position: absolut; left: 100px; top: 200px; } But they only move as long as you hover over the image. To permanetly move a image you need some javascript. You can use a CSS class .move-img { position: absolute: left: 100px; } and add this class dynamically to your image using JS. <script> function moveImage() { var image = document.getElementById('yourImg'); image.className += 'move-img'; } </script> Now you can call this function on a button click for example. <button onclick="moveImage()">Move img</button>
5th Mar 2017, 3:48 PM
qobus
0
thnx
5th Mar 2017, 3:50 PM
VishalYumnam
VishalYumnam - avatar