HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> body{ height: 260px; background-image: url("ocean.jpg"); background-repeat: no-repeat; background-size: contain; color: #ffffff; } </style> </head> <body> <h1>CSS background-size Property</h1> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("body")[0]; function myFunction(){ x.style.backgroundSize = "cover"; } </script> <p><strong>Note</strong>: Click on the button to set the background-size to cover.</p> </body> </html>
OUTPUT
×

Save as Private