HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ position: relative; border: 1px solid black; height: 250px; } img{ position: absolute; } </style> </head> <body> <h1>CSS top Property</h1> <div> <img src="apple.png"> </div> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("img")[0]; function myFunction(){ x.style.top = "100%"; } </script> <p><strong>Note</strong>: Click on the button to start the image from 100% from the start of the div.</p> </body> </html>
OUTPUT
×

Save as Private