0

I'm trying to use a stock photo to cover my page. For some reason I cannot seem to get this to work. My image just refuses to cover the page.

#cover {
 background-image: url("https://i.sstatic.net/QE9pP.jpg");
 background-size: cover;
 background-size: center center;
 background-repeat: no-repeat;
 background-attachment: fixed;
 background-color: #464646;
}
.cover-content {
 color: hsla(182, 100%, 28%, 1);
 font-family: font-family: 'Gravitas One', cursive;
 font-size: 400%;
 text-align: center;
}
<div id="cover">
 <div class="cover-content">
 <h1>Snowfall Design Studio</h1>
 </div>
</div>

Vadim Ovchinnikov
14.1k7 gold badges68 silver badges95 bronze badges
asked Jul 12, 2017 at 15:22
1
  • Minor point, but worth mentioning even though your question is already answered: baclground-size: center center is invalid and should either be removed, or changed to background-position: center. Commented Jul 12, 2017 at 15:45

2 Answers 2

2

Your page does not cover the whole viewport. If you want an image to cover the whole screen, put the background-image on the html or body element

html {
 height: 100%;
}
body {
 min-height: 100%;
 background-image: url("https://i.sstatic.net/QE9pP.jpg");
 background-size: cover;
 background-position: center center;
 background-repeat: no-repeat;
 background-attachment: fixed;
 background-color: #464646;
}
.cover-content {
 color: hsla(182, 100%, 28%, 1);
 font-family: font-family: 'Gravitas One', cursive;
 font-size: 400%;
 text-align: center;
}
<div id="cover">
 <div class="cover-content">
 <h1>Snowfall Design Studio</h1>
 </div>
</div>

answered Jul 12, 2017 at 15:26
Sign up to request clarification or add additional context in comments.

1 Comment

background-size: center center is also invalid. May be a minor point, but worth mentioning I think.
0

Here is an example of the image covering the whole page: https://codepen.io/anon/pen/owJVgq

You needed to move the background images to the body tag and add a viewport of:

<meta name="viewport" content="width=device-width, initial-scale=1">

If you are looking for this section to be just a section and have more content below the picture, this is what you're looking for: https://codepen.io/anon/pen/BZvbNe

Again you need to add the viewport, but also add:

body {
 margin: 0px;
 padding: 0px;
}
answered Jul 12, 2017 at 15:38

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.