Ask coding questions

← Back to all posts
How do I add a background image to my website?
RYANBEEBE (4)

How do I add a background image to my website

Answered by enigma_dev (7080) [earned 5 cycles]
View Answer
Commentshotnewtop
enigma_dev (7080)

As I understand you want to have a fullsize background image. This can be done via

body, html {
  height: 100%;
}

.bg {
  /* The image used */
  background-image: url("img.jpg");

  /* Full height */
  height: 100%;

  /* Center and scale the image nicely */
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}
katyadee (1198)

@enigma512 Thanks Enigma! We appreciate all your contributions :)

katyadee (1198)

Hey @RyanBeebe, I edited your post so your question is in the subject line. That way users who might have an answer can find it more easily :)