Is there a way to fix a position on the x-axis only? So when a user scrolls up, the div tag will scroll up with it, but not side to side?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
Very easy solution is:
This is an old thread but CSS3 has a solution.
Have a look at this blog post.
Demonstration:
And this documentation.
No, it's not possible with pure CSS. That kind of positioning fixes the element in the viewport. I'd suggest simply fixing the element to one of the sides of the viewport (i.e. top, bottom, left or right) so that it doesn't interfere with other content.
Updated the script to check the start position:
}
If your block is originally positioned as static, you may want to try this
This is a very old thread, but I have found a pure CSS solution to this using some creative nesting. I wasn't a fan of the jQuery method at all...
Fiddle here: https://jsfiddle.net/4jeuv5jq/