1

I hope you'll have an answer for me. In CSS there's the property background-attachment: fixed; which looks really fancy, so my question is there any property which I can use to "fix" some divs with text's etc. in the document? If not, how to solve it in Typescript? I hope you know what I mean

//edit: Okay, i will try to describe it: with the property background-attachment: fixed; the background of a div is fixed but not it's content, so a parallax effect appears, like this: w3schools.com/howto/tryhow_css_parallax_demo.htm And know I wanted to know if it is possible to do the same with the content like texts etc.

Markus G.
  • 1,620
  • 2
  • 25
  • 49

1 Answers1

0

Can you try it like this ?

HTML

<div class="fixedContainer">
    This is experimental
</div>
<div class="otherContainer"> </div>

And here goes your style

CSS

<style>
.fixedContainer {
    background-color:#ddd;
    position: fixed;
    padding: 2em;
    left: 50%;
    top: 0%;
    transform: translateX(-50%);
}

.otherContainer {
    height:1000px;
    background-color:#bbb;
}

</style>

Credit originally goes to : this link and stackoverflow user aaronk6 and Joseph Marikle at their posts :

this link and at this link respectively.

Community
  • 1
  • 1
Surajit Biswas
  • 779
  • 7
  • 25
  • Nope, doesn't work, the fixedContainer is fixed but not that fixed i want, maybe when I say the word "parallax fixed"? you know what i mean? – Markus G. Aug 05 '16 at 07:18
  • Nope, I didn't .What is "parallax fixed" ? – Surajit Biswas Aug 05 '16 at 07:21
  • Okay, i will try to describe it: with the property background-attachment: fixed; the background of a div is fixed but not it's content, so a parallax effect appears, like this: http://www.w3schools.com/howto/tryhow_css_parallax_demo.htm And know I wanted to know if it is possible to do the same with the content like texts etc. – Markus G. Aug 05 '16 at 07:25
  • Here an attachment (as background) is fixed. It's an image. But you want it to be a div (with some text content) fixed here right ? – Surajit Biswas Aug 05 '16 at 07:27
  • yes right. The background in my div is already fixed (and looks nice btw), but i also want the content to be fixed like the background. – Markus G. Aug 05 '16 at 07:29
  • Can you check out this one : https://davidwalsh.name/demo/parallax.php , If it helps you ! – Surajit Biswas Aug 05 '16 at 07:34
  • Also you may check this like : http://keithclark.co.uk/articles/practical-css-parallax/feature-detection/ – Surajit Biswas Aug 05 '16 at 07:37
  • I think i will look at transform translate and i hope i will get it. thanks – Markus G. Aug 05 '16 at 07:45