/    Sign up×
Community /Pin to ProfileBookmark

How can I cover properly
element with a backgound image?

Hi
I have a rather complicated background image so it is difficult to align all the elements on the page with the image. While I could get everything aligned properly on most screens, on some screens something gets shifted. As a solution, I thought of splitting the background image into 3 sub-images, each should be placed in a <div> tag. The <div> tags are arranged vertically, one under the other, which is the default arrangement.
The problem is that I can’t get each of the <div> tags covered properly with its background image. Thus, if I use `background-size: contain;` in the css, there are margins on each side of the image, which results in a space between the <div>tags. If I use `background-size: cover;` instead, there are no margins, no empty space, but the background is not scaled with the window. Depending on the screen resolution, it may not fit in even when the browser window is full screen and scroll bars may appear.
Is there a way to cover the browser window with these 3 sub-images such that there is no empty space between them (like when using `background-size: cover;` ) and at the same time everything scales properly with the window (like when using `background-size: contain;` )?

to post a comment
CSSHTML

7 Comments(s)

Copy linkTweet thisAlerts:
@ldor108authorMar 25.2021 — @ldor108#1629647 Just some additional information. I tried to remove that empty space by introducing a negative margin-top or by specifying position: relative and then a negative top value. Either way it works but only for a specific window size. When resizing the window (or trying on a screen with a different resolution) everything gets broken.
Copy linkTweet thisAlerts:
@SuitsMeOnlineMar 25.2021 — Either way it works but only for a specific window size. When resizing the window (or trying on a screen with a different resolution) everything gets broken.

**URL removed by Site Staff so it doesn't look like you're spamming us. Please don't post it again.**
Copy linkTweet thisAlerts:
@ldor108authorMar 25.2021 — @SuitsMeOnline#1629656 Yes, that's what I mean. So I am trying to find a way to seamlessly stitch the 3 images so that they would remain stitched when the window is resized and also would be scaled with the window. I am not sure if there is a way to do that but I remember seeing background made that way on some websites. Maybe those sites were designed using tables, not div tags, I don't know that.
Copy linkTweet thisAlerts:
@SuitsMeOnlineMar 25.2021 — @ldor108#1629659

ok Dear Thank you so Much
Copy linkTweet thisAlerts:
@cootheadMar 25.2021 — Hi there ldor108,

If we had a link to the page, members would be able

to see the problem and possibly find a solution to it.

[i]coothead[/i]
Copy linkTweet thisAlerts:
@SuitsMeOnlineApr 23.2021 — @coothead#1629661 Sure
Copy linkTweet thisAlerts:
@ThemeSoulsMay 09.2021 — Yah

if you are provide the page link than easy to solve you problems
×

Success!

Help @ldor108 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...