锚链接到同一页面上的元素不起作用?

时间:2017-06-30 18:25:04

标签: html

我列表中的href链接没有将页面移动到同一页面上的相应元素。我可以在屏幕上看到更改但屏幕上没有任何内容。

<div id="allSections">

    <!--ALL SIDE SECTIONS-------------------------->
     <nav>
        <ul>
            <li><a class="scroll" href="#hero">Welcome</a></li>
            <li><a class="scroll" href="#branches">Venues</a></li>
            <li><a class="scroll" href="#reservation">Reservation</a></li>
            <li><a class="scroll" href="#contactus">Contact Us</a></li>
            <li><a class="scroll" href="#map">Map</a></li>
        </ul>
    </nav>

    <div>
        <section name="#hero" id="#hero">
            <div>
                <div id="imgContainer">
                    <img src="images/2017-02-26_004802.png">
                </div>
            </div>
        </section>

        <section name="#branches" id="#branches"></section>

        <section name="#reservation" id="#reservation"></section>

        <section name="#contactus" id="#contactus"></section>

        <section name="#map" id="#map"></section>
    </div>

    <!--ALL SIDE SECTIONS----------------------------->

</div>

2 个答案:

答案 0 :(得分:1)

将您的部分更改为:

   <section id="branches"></section>

   <section id="reservation"></section>

   <section id="contactus"></section>

   <section id="map"></section>

答案 1 :(得分:0)

以下是解释问题:

https://www.w3schools.com/tags/att_a_name.asp