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
If you want to fix it on the right, for example, use
justify-content: flex-end
.More: http://www.w3schools.com/cssref/css3_pr_justify-content.asp
Yes, You actually can do that only by using CSS...
Tell me if it works
I stumbled on this post looking for a nice way to keep my header/navigation bar centered and responsive to size changes.
As we scroll, the bar moves upwards off the screen. If you scroll left/right it will stay fixed.
On parent div you can add
Its a simple technique using the script also. You can check a demo here too.
JQuery
CSS
Update Credit: @PierredeLESPINAY
As commented, to make the script support the changes in the css without having to recode them in the script. You can use the following.
Demo :)