簡體   English   中英

如何在使用錨點的情況下嵌套到特定部分?

[英]How to jump to a specific section, while nested, with an anchor?

我有一個網站,我一直在努力,我想解決一個我以前沒有偶然發現的問題。 它與錨點和嵌套部分有關。

所以代碼看起來像這樣:

<html>
    <head></head>
    <body>
        <section id="sections"> <!-- FAILS the jumping -->
            <section id="abo0">
            </section>
            <section id="abo1">
            </section>
        </section>
    </body>
</html>

現在使用瀏覽器,我可以通過像href =“?#abo0”之類的錨點在不同的section-tags之間跳轉。 如果父節 - 標簽(id =“節”)不在代碼中。 使用嵌套部分在瀏覽器中失敗了什么?

我嘗試過“?#sections#abo0”之類的東西,但似乎沒有什么工作,除了刪除父節標記。

有關如何解決這個奇怪問題的任何想法? 我真的需要這個嵌套部分設置,因為標題將是不正確的,否則,就像我的網站目前的設計方式。

謝謝! 親切的問候goldenmaza

刪除帶有id section並使用此section滾動

http://yourwebsite.com/page.html#abo1

你的HTML代碼

<html>
<head></head>
<body>

        <section id="abo0" style="height:2000px">sd
        </section>
        <section id="abo1" style="height:2000px">
            asdf
        </section>

</body>

由於並非所有代碼都可用,我無法看到它是如何使用和失敗的,所以這是第一個展示如何/應該使用它的示例。

如果我錯過了某些內容,請發表評論,我會調整我的解決方案。

 #abo0, #abo1 { height: 500px; border: 1px solid gray; margin: 10px; } 
 <a href="#abo0">Link 0</a> <a href="#abo1">Link 1</a> <section id="sections"> <section id="abo0"> Text 0 <br><a href="#abo1">Link 1</a> <br><a href="#">Back to top</a> </section> <section id="abo1"> Text 1 <br><a href="#abo0">Link 0</a> <br><a href="#">Back to top</a> </section> </section> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM