Ask coding questions

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

How do I add a background image to my website

Answered by qualladoom (357) [earned 5 cycles]
View Answer
Comments
hotnewtop
qualladoom (357)

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 (1273)

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

katyadee (1273)

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 :)