
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set Starting Position of Background Image in JavaScript DOM
To set the starting position of a background image in JavaScript, use the backgroundposition property. It allows you to set the position of the image.
Example
You can try to run the following code to learn how to set all the position of a background image with JavaScript −
<!DOCTYPE html> <html> <head> <style> body { background-repeat: no-repeat; } </style> </head> <body> <button onclick="display()">Click to Set background image</button> <script> function display() { document.body.style.backgroundImage = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg')"; document.body.style.backgroundPosition="top right"; } </script> </body> </html>
Advertisements