LeonLatex Posted August 16, 2022 Share Posted August 16, 2022 Finally, I found out how to scale background images automatically depending on the viewport/screen size and the screen resolution. I bought myself a new book about CSS3 and HTML5. But there is a thing missing in the book. It doesn't tell me..... Ok, I start over. I want to use a different background image on different pages. As I have understood I "Have" to use CSS background-***** in combination with the <body class="******"> tag. Is this right, or can I use it with a <div> tag too? I mean as a background image in a <div class='****** with width and height 100%" so the <div> covers the screen at all time? Will the CSS background-***** do the same in a <div> as in a <body> tag? Yes I know i could use a lot of time on this by testing it out my self, but spare me the time by asking in a hope if some of you know the answer. Quote Link to comment https://forums.phpfreaks.com/topic/315188-css-background-image-size-etc/ Share on other sites More sharing options...
Barand Posted August 16, 2022 Share Posted August 16, 2022 6 hours ago, LeonLatex said: Yes I know i could use a lot of time on this by testing it out my self Yes, you could. Quote Link to comment https://forums.phpfreaks.com/topic/315188-css-background-image-size-etc/#findComment-1599421 Share on other sites More sharing options...
Solution morocco-iceberg Posted October 2, 2022 Solution Share Posted October 2, 2022 You can apply the background css rules to both body and div tags, the thing to keep in mind will be that the background will be relative to it's container (element), so unless you have also made the div take up the entire view you will have a different visual effect compared to a body tag. You may also find that you need to specify a height for the div to be able to see the background if the div doesn't contain any content from which to derive a height Quote Link to comment https://forums.phpfreaks.com/topic/315188-css-background-image-size-etc/#findComment-1601269 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.