- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Setting Background Position in CSS
The CSS background-position property is used to set an initial position for a background image relative to the origin.
Syntax
The syntax of CSS background-position property is as follows −
Selector { background-position: /*value*/ }
The following examples illustrate CSS background-position property −
Example
<!DOCTYPE html> <html> <head> <style> div { margin: 30px; padding: 100px; background-image: url("https://www.tutorialspoint.com/images/C-programming.png"), url("https://www.tutorialspoint.com/images/Swift.png"), url("https://www.tutorialspoint.com/images/xamarian.png"); background-repeat: no-repeat; background-position: 15% 20%, top, right; border: 1px solid; } </style> </head> <body> <div> </div> </body> </html>
Output
This gives the following output −
Example
<!DOCTYPE html> <html> <head> <style> p { margin: 20px; padding: 80px; background-image: url("https://www.tutorialspoint.com/images/dbms.png"), url("https://www.tutorialspoint.com/images/Operating-System.png"); background-repeat: no-repeat; background-position: 0 0, bottom right; background-color: lemonchiffon; } </style> </head> <body> <p>This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. </p> </body> </html>
Output
This gives the following output −
Advertisements