CSS定位中的”Sticky”和”Fixed”不如预期工作。

huangapple go评论69阅读模式
英文:

CSS Positioning Sticky and fixed not working as expected

问题

我试图让第一和最后一部分保持固定,只有中间部分可以滚动,同时保持导航栏、第一部分和最后一部分保持不变,但当我给导航栏设置固定位置时,它会保持固定不动,但所有其他部分在向下滚动时会穿过它,就像在它的上面一样。另外,如果我将第一部分的位置固定,就会像这样。备注:我正在使用Tailwind CSS

英文:

CSS定位中的”Sticky”和”Fixed”不如预期工作。I am trying to make the first and last section to be fixed and only the middle section to be able to scroll down while keeping the navbar and the first and the last section to remain the same but when I give the navbar a position of fixed it remain fixed there but all the other sections when scrolled down move through it like on top of it
And also if I give the position fixed to the first section it will be like this.
PS: I am using Tailwind CSS

The code:
https://gist.github.com/itisMilan/52ea39f41029b1dc674136b2ad7204b5

答案1

得分: 2

你可以将你的布局重新设计成网格,并让中间的内容元素可滚动。参见此Tailwind Play

英文:

You could restructure your layout as a grid, and have the middle content element by scrollable. See this Tailwind Play.

huangapple
  • 本文由 发表于 2023年4月17日 00:03:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76028840.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定