固定顶栏与命名锚点 [英] Fixed topbar vs named anchors

查看:89
本文介绍了固定顶栏与命名锚点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个顶部有 position:fixed ,它还包含锚链接(< a href =#someid> jdjd<问题是目标放在视口的顶部(固定顶部栏后面)。

>

我如何修复浏览器滚动,使目标显示在顶部栏下面?

解决方案

不知道为什么你被downvoted,它似乎是一个诚实的好问题。



我会把一个 margin-top ,等于固定顶栏的高度。



http://jsfiddle.net/justiceerolin/KfMLJ/ 作为示例


I have a topbar with position:fixed which also contains anchor links (<a href="#someid">jdjd</a>).

The problem is that the target is placed in the top of the viewport (behind the fixed topbar).

how can I fix so the the browser scrolls so that the target is shown just below the topbar?

解决方案

Not sure why you're being downvoted, it seems like an honest a good question.

I'd put a margin-top on the viewport, equal to the height of the fixed topbar.

http://jsfiddle.net/justiceerolin/KfMLJ/ as an example

这篇关于固定顶栏与命名锚点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆