固定頁眉與頁內錨點重疊 - Fixed page header overlaps in-page anchors

問題:

If I have a non-scrolling header in an HTML page, fixed to the top, having a defined height:如果我在 HTML 頁面中有一個非滾動標題,固定在頂部,具有定義的高度:

Is there a way to use the URL anchor (the #fragment part) to have the browser scroll to a certain point in the page, but still respect the height of the fixed element without the help of JavaScript ?有沒有辦法使用 URL 錨點( #fragment部分)讓瀏覽器滾動到頁面中的某個點,但在沒有 JavaScript 幫助的情況下仍然尊重固定元素的高度?

http://example.com/#bar
WRONG (but the common behavior):         CORRECT:
+---------------------------------+      +---------------------------------+
| BAR///////////////////// header |      | //////////////////////// header |
+---------------------------------+      +---------------------------------+
| Here is the rest of the Text    |      | BAR                             |
| ...                             |      |                                 |
| ...                             |      | Here is the rest of the Text    |
| ...                             |      | ...                             |
+---------------------------------+      +---------------------------------+

解決方案:

參考一: https://en.stackoom.com/question/H8yx
參考二: https://stackoom.com/question/H8yx
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章