Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个粘性导航,当它被捕获时,它会在浏览器窗口的顶部占据大约 80 像素的空间。导航的一部分包含跳转到部分导航,它将用户带到页面上与导航中的链接相关的部分(您知道这是如何工作的)。
问题是一旦用户单击跳转链接,它会将部分设置在窗口顶部,该部分使用粘性导航覆盖部分名称,只是突然显示一个无标题的内容。
有没有办法抵消粘性导航占用的空间,以便用户可以在导航点击时看到部分的标题?
理想情况下,这将是一个 CSS 修复。建议?
将padding-top: 80px;(导航的高度)添加到每个部分的顶部。
padding-top: 80px;
如果这弄乱了您的设计,您可以将其设为 a margin,然后margin-bottom:-80px;在上方元素的底部添加一个负数,以保持设计一致。
margin
margin-bottom:-80px;