Jump to content

CSS background-image-size etc


LeonLatex
Go to solution Solved by morocco-iceberg,

Recommended Posts

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. 

Link to comment
Share on other sites

  • 1 month later...
  • Solution
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.