this post was submitted on 03 Sep 2024
10 points (91.7% liked)

CSS

484 readers
1 users here now

founded 1 year ago
MODERATORS
 

Hi everyone,

I would like one of my div to have an background-attachment: fixed

But the background still scroll ๐Ÿ˜ค

This div is under html body div div div div div

and it CSS properties are

#TheDiv {
    min-height: 100vh;
    min-width: 100vw;
    background-image: url('/anImage.jpg');
    background-size: cover;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-position: center center;
    position: absolute;
    left: 0;
    padding: 40px;
    box-sizing: border-box }

Any Ideas, what could cause the background to scroll anyway ?

Thanks

top 2 comments
sorted by: hot top controversial new old
[โ€“] m4m4m4m4@lemmy.world 3 points 1 month ago

Can you provide a live test version, like in codepen or something?

[โ€“] Corsair@programming.dev 1 points 1 month ago* (last edited 1 month ago)

I think I found the cause.

one of the parent div have is properties perspective and it seem to be the problem... (Firefox 115*)

So I created an dirty workaround ;)