0

I created a background and attached to body it is scrolling to the right fine. but when I attach to a div it doesn't seem to be attached. the scrolling happens in the body.

Here is the link when attached to the body

background-attachment: fixed;

vs when attached to div

coool
  • 8,085
  • 12
  • 60
  • 80
  • inline-flex instead of flex (and min-width:100%) – Temani Afif Aug 12 '21 at 14:48
  • Please read [Something on my web site doesn't work. Can I just paste a link to it?](http://meta.stackoverflow.com/questions/125997/something-on-my-web-site-doesnt-work-can-i-just-paste-a-link-to-it). Questions that depend on external resources to be understood become useless when the external resource goes away or is fixed. Create a [MCVE] and put it in **the question itself** instead. Stackoverflow does support [inline live demos](https://stackoverflow.blog/2014/09/16/introducing-runnable-javascript-css-and-html-code-snippets/) – Quentin Aug 12 '21 at 14:48
  • The `.flex` div doesn't have a width set, so it only flexes to the viewport width. – Sean Stopnik Aug 12 '21 at 14:48
  • Also read what background attachment is supposed to do: https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment – Quentin Aug 12 '21 at 14:49
  • and width instead of flex-basis – Temani Afif Aug 12 '21 at 14:49
  • @Quentin I think it is not a "my website doesn't work thing". It is a minimal reproduceable example... – coool Aug 12 '21 at 14:50
  • 1
    @coool I think that comment was more about the fact your example was only available on an external site rather than in the question (Since any changes to the content at that link or if the site ever goes down, this question becomes meaningless) – DBS Aug 12 '21 at 14:57
  • @TemaniAfif inline-flex and width does the trick. – coool Aug 12 '21 at 14:57
  • @DBS yes absolutely agree – coool Aug 12 '21 at 14:58

0 Answers0