Background-image cover doesn't work on smaller screens











up vote
1
down vote

favorite












EDIT : Fixed it by manually setting a width ( auto ) and a height as a background-size. ( background-size: auto 1100px; )



Hey I'd like to use an image as a background for my header.
Here's what it looks like now :
Desktop



There's a navbar above that I can't really show and that's not really the point here.
Now here's my mobile version :
Mobile version



As you can see, there's a blank space that I don't want here. I've tried using vh/vw, setting the body height at 100%, but it doesn't work.






.home .part1-img-container {
min-height: 650px;
background-color: grey;
background: url(assets/img/brooklyn.jpg) no-repeat center center scroll;
background-size: cover;
background-repeat: no-repeat;
text-align: center;
/*padding-top: 70px;*/
border-bottom-left-radius: 50% 10%;
border-bottom-right-radius: 50% 10%;
margin-bottom: 10px;
background-position-y: -187px;
}

<div class="part1 col-md-12 col-lg-12 p-0">
<div class="part1-img-container">

</div>
</div>





There's a block of text in the header, but I'll take care of that, right now the problem is the blank space at the bottom, anyone can help me ?



Thanks a lot !










share|improve this question




















  • 1




    have you tried to do this without setting a min-height
    – Toxide82
    Nov 8 at 13:13












  • The problem is clearly the min-height, I was added an answer but I misunderstood the question, so @Toxide82 seems to be right.
    – Marcos Pérez Gude
    Nov 8 at 13:15










  • Still doesn't work :/ I think the min-height sets the minimum height for the div, not for the background-image unfortunately
    – Mael Landrin
    Nov 8 at 13:16












  • I don't have a media query on that, I think I found a fix by manually setting the width and height of the background image, I'll update my original post !
    – Mael Landrin
    Nov 8 at 13:30






  • 1




    I have made a fiddle out of the code you have presented. Without background-position-y: -187px; it is working fine in mobile and desktop both. jsfiddle.net/51f7w6q0/13
    – AKNair
    Nov 8 at 13:33















up vote
1
down vote

favorite












EDIT : Fixed it by manually setting a width ( auto ) and a height as a background-size. ( background-size: auto 1100px; )



Hey I'd like to use an image as a background for my header.
Here's what it looks like now :
Desktop



There's a navbar above that I can't really show and that's not really the point here.
Now here's my mobile version :
Mobile version



As you can see, there's a blank space that I don't want here. I've tried using vh/vw, setting the body height at 100%, but it doesn't work.






.home .part1-img-container {
min-height: 650px;
background-color: grey;
background: url(assets/img/brooklyn.jpg) no-repeat center center scroll;
background-size: cover;
background-repeat: no-repeat;
text-align: center;
/*padding-top: 70px;*/
border-bottom-left-radius: 50% 10%;
border-bottom-right-radius: 50% 10%;
margin-bottom: 10px;
background-position-y: -187px;
}

<div class="part1 col-md-12 col-lg-12 p-0">
<div class="part1-img-container">

</div>
</div>





There's a block of text in the header, but I'll take care of that, right now the problem is the blank space at the bottom, anyone can help me ?



Thanks a lot !










share|improve this question




















  • 1




    have you tried to do this without setting a min-height
    – Toxide82
    Nov 8 at 13:13












  • The problem is clearly the min-height, I was added an answer but I misunderstood the question, so @Toxide82 seems to be right.
    – Marcos Pérez Gude
    Nov 8 at 13:15










  • Still doesn't work :/ I think the min-height sets the minimum height for the div, not for the background-image unfortunately
    – Mael Landrin
    Nov 8 at 13:16












  • I don't have a media query on that, I think I found a fix by manually setting the width and height of the background image, I'll update my original post !
    – Mael Landrin
    Nov 8 at 13:30






  • 1




    I have made a fiddle out of the code you have presented. Without background-position-y: -187px; it is working fine in mobile and desktop both. jsfiddle.net/51f7w6q0/13
    – AKNair
    Nov 8 at 13:33













up vote
1
down vote

favorite









up vote
1
down vote

favorite











EDIT : Fixed it by manually setting a width ( auto ) and a height as a background-size. ( background-size: auto 1100px; )



Hey I'd like to use an image as a background for my header.
Here's what it looks like now :
Desktop



There's a navbar above that I can't really show and that's not really the point here.
Now here's my mobile version :
Mobile version



As you can see, there's a blank space that I don't want here. I've tried using vh/vw, setting the body height at 100%, but it doesn't work.






.home .part1-img-container {
min-height: 650px;
background-color: grey;
background: url(assets/img/brooklyn.jpg) no-repeat center center scroll;
background-size: cover;
background-repeat: no-repeat;
text-align: center;
/*padding-top: 70px;*/
border-bottom-left-radius: 50% 10%;
border-bottom-right-radius: 50% 10%;
margin-bottom: 10px;
background-position-y: -187px;
}

<div class="part1 col-md-12 col-lg-12 p-0">
<div class="part1-img-container">

</div>
</div>





There's a block of text in the header, but I'll take care of that, right now the problem is the blank space at the bottom, anyone can help me ?



Thanks a lot !










share|improve this question















EDIT : Fixed it by manually setting a width ( auto ) and a height as a background-size. ( background-size: auto 1100px; )



Hey I'd like to use an image as a background for my header.
Here's what it looks like now :
Desktop



There's a navbar above that I can't really show and that's not really the point here.
Now here's my mobile version :
Mobile version



As you can see, there's a blank space that I don't want here. I've tried using vh/vw, setting the body height at 100%, but it doesn't work.






.home .part1-img-container {
min-height: 650px;
background-color: grey;
background: url(assets/img/brooklyn.jpg) no-repeat center center scroll;
background-size: cover;
background-repeat: no-repeat;
text-align: center;
/*padding-top: 70px;*/
border-bottom-left-radius: 50% 10%;
border-bottom-right-radius: 50% 10%;
margin-bottom: 10px;
background-position-y: -187px;
}

<div class="part1 col-md-12 col-lg-12 p-0">
<div class="part1-img-container">

</div>
</div>





There's a block of text in the header, but I'll take care of that, right now the problem is the blank space at the bottom, anyone can help me ?



Thanks a lot !






.home .part1-img-container {
min-height: 650px;
background-color: grey;
background: url(assets/img/brooklyn.jpg) no-repeat center center scroll;
background-size: cover;
background-repeat: no-repeat;
text-align: center;
/*padding-top: 70px;*/
border-bottom-left-radius: 50% 10%;
border-bottom-right-radius: 50% 10%;
margin-bottom: 10px;
background-position-y: -187px;
}

<div class="part1 col-md-12 col-lg-12 p-0">
<div class="part1-img-container">

</div>
</div>





.home .part1-img-container {
min-height: 650px;
background-color: grey;
background: url(assets/img/brooklyn.jpg) no-repeat center center scroll;
background-size: cover;
background-repeat: no-repeat;
text-align: center;
/*padding-top: 70px;*/
border-bottom-left-radius: 50% 10%;
border-bottom-right-radius: 50% 10%;
margin-bottom: 10px;
background-position-y: -187px;
}

<div class="part1 col-md-12 col-lg-12 p-0">
<div class="part1-img-container">

</div>
</div>






css background-image cover






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 13:33

























asked Nov 8 at 13:10









Mael Landrin

277




277








  • 1




    have you tried to do this without setting a min-height
    – Toxide82
    Nov 8 at 13:13












  • The problem is clearly the min-height, I was added an answer but I misunderstood the question, so @Toxide82 seems to be right.
    – Marcos Pérez Gude
    Nov 8 at 13:15










  • Still doesn't work :/ I think the min-height sets the minimum height for the div, not for the background-image unfortunately
    – Mael Landrin
    Nov 8 at 13:16












  • I don't have a media query on that, I think I found a fix by manually setting the width and height of the background image, I'll update my original post !
    – Mael Landrin
    Nov 8 at 13:30






  • 1




    I have made a fiddle out of the code you have presented. Without background-position-y: -187px; it is working fine in mobile and desktop both. jsfiddle.net/51f7w6q0/13
    – AKNair
    Nov 8 at 13:33














  • 1




    have you tried to do this without setting a min-height
    – Toxide82
    Nov 8 at 13:13












  • The problem is clearly the min-height, I was added an answer but I misunderstood the question, so @Toxide82 seems to be right.
    – Marcos Pérez Gude
    Nov 8 at 13:15










  • Still doesn't work :/ I think the min-height sets the minimum height for the div, not for the background-image unfortunately
    – Mael Landrin
    Nov 8 at 13:16












  • I don't have a media query on that, I think I found a fix by manually setting the width and height of the background image, I'll update my original post !
    – Mael Landrin
    Nov 8 at 13:30






  • 1




    I have made a fiddle out of the code you have presented. Without background-position-y: -187px; it is working fine in mobile and desktop both. jsfiddle.net/51f7w6q0/13
    – AKNair
    Nov 8 at 13:33








1




1




have you tried to do this without setting a min-height
– Toxide82
Nov 8 at 13:13






have you tried to do this without setting a min-height
– Toxide82
Nov 8 at 13:13














The problem is clearly the min-height, I was added an answer but I misunderstood the question, so @Toxide82 seems to be right.
– Marcos Pérez Gude
Nov 8 at 13:15




The problem is clearly the min-height, I was added an answer but I misunderstood the question, so @Toxide82 seems to be right.
– Marcos Pérez Gude
Nov 8 at 13:15












Still doesn't work :/ I think the min-height sets the minimum height for the div, not for the background-image unfortunately
– Mael Landrin
Nov 8 at 13:16






Still doesn't work :/ I think the min-height sets the minimum height for the div, not for the background-image unfortunately
– Mael Landrin
Nov 8 at 13:16














I don't have a media query on that, I think I found a fix by manually setting the width and height of the background image, I'll update my original post !
– Mael Landrin
Nov 8 at 13:30




I don't have a media query on that, I think I found a fix by manually setting the width and height of the background image, I'll update my original post !
– Mael Landrin
Nov 8 at 13:30




1




1




I have made a fiddle out of the code you have presented. Without background-position-y: -187px; it is working fine in mobile and desktop both. jsfiddle.net/51f7w6q0/13
– AKNair
Nov 8 at 13:33




I have made a fiddle out of the code you have presented. Without background-position-y: -187px; it is working fine in mobile and desktop both. jsfiddle.net/51f7w6q0/13
– AKNair
Nov 8 at 13:33

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208458%2fbackground-image-cover-doesnt-work-on-smaller-screens%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208458%2fbackground-image-cover-doesnt-work-on-smaller-screens%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff