Backgrounds in CSS

Backgrounds in CSS ka use elements ke piche color ya image add karne ke liye hota hai, jisse webpage ka design aur look better ban jata hai.


Background Color

Backgrounds in CSS me background-color property se kisi element ka background color set kiya jata hai.

Example:

Backgrounds in CSS

Aap color ko different formats me bhi likh sakte ho jaise color name, HEX ya RGB.


Background Image

background-image property se element ke background me image lagayi jati hai.

Example:

Background Image

Note: Aisi image use karo jo text ko readable rakhe.


Background Repeat

By default image repeat hoti hai horizontally aur vertically. Isko control karne ke liye background-repeat use hota hai.

Example:

Background Repeat
  • repeat-x → sirf horizontal repeat
  • repeat-y → sirf vertical repeat
  • no-repeat → image ek hi baar show hogi

Background Position

background-position se image ki exact position set karte hain.

Example:

Background Position

Default position top-left hoti hai.


Background Attachment

background-attachment decide karta hai ki image scroll kare ya fixed rahe.

Example:

Background Attachment
  • fixed → image scroll nahi karegi
  • scroll → image page ke saath move karegi

Background Shorthand

Backgrounds in CSS me saare properties ko ek line me likhne ke liye shorthand use hota hai.

Example:

Background Shorthand

Isme multiple properties ek saath combine hoti hain jaise:

  • background-color
  • background-image
  • background-repeat
  • background-position

Conclusion

Backgrounds in CSS webpage ke design ka important part hain. Inki help se tum colors aur images use karke layout ko attractive aur clean bana sakte ho.

Leave a Comment