Css background image and tables

#1

I have a background image who had these properties

background-attachment: fixed;
    background-size: cover;
    background-position: center;
    height: 100vh;
    height: 100%;

it works if there are divs or elements in the table or the parent div otherwise it shows like this


How can i make it work?
Thanks

#2

100% of what?

Your last rule of height:100% overrides height:100vh

Unless the parent of that element has a set height then height:100% is ignored. Not only that, you probably meant to say min-height:100%; That way it can expand when content exceeds the viewport’s height.

Are you sure you need a table for that? It doesn’t look like tabular data to me.

1 Like
#3

I just tried everything, table or no table, if there is no content the space is white thats my problem.

#4

Do you have a link to the page in question so we can properly see what you are doing?

You do realise that background-attachment fixed places the image in respect of the viewport and not the element you applied it to? You will only see the background in the element when your element passes over the place where the background is placed. If your element is only content height then the image is only seen in the content part of your element and while that element is over the position the fixed attachment has been placed.

As Ray suggests it sounds as though your element has only content height which means you will only see part of the image assuming the element is over the position that the image has been placed.

If you place the fixed attachment on the body element it will cover the whole viewport and be available at all time if that’s what you wanted.

However without full html and css that’s just a guess :slight_smile:

1 Like
closed #5

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.