2
For the background to be 100% height you also need to set the height in HTML. I also suggest using the background-size
as cover
. Link to the documentation: https://developer.mozilla.org/en-US/docs/Web/CSS/background-size
In this example below you can see that the image always gets to 100% height occupies the width of the device without losing the "ratio"
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
background-image: url(https://www.digitaltrends.com/wp-content/uploads/2012/04/open-book.jpg);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
Screenshot of the result in Chrome Devtools simulating the background on mobile device.
worked.thanks.
– Diana Madeira
This ai is responsive background, the rest will remain non-responsive.
– Sveen
@Sveen by the code posted along with the question assumed it would be about the background. If it were to be the full page I believe I would have the rest of the code in question... Even feel free to answer as you see fit, the author can change the acceptance of the answer whenever he wants if something comes up that he thinks best served what he needed. There are questions out there with more than 10 answers.
– hugocsl
I’m not taking credit for it, I thought so, but look https://answall.com/questions/286307/texto-responsivo-html
– Sveen
@Sveen may seem strange, but what he did is absolutely right! Under STOF rules it is indicated that no more than one question is asked at the same time. He asked BG a question, now one for the other things he needs. Better than asking a question with several things to answer at the same time. After a look here, there are several debates on this point https://pt.meta.stackoverflow.com/
– hugocsl