当我想要进入下拉菜单的主页时,为什么我的导航链接无法正常工作? [英] Why is my nav link not working when I want to go to the main page of the drop down menu?

查看:50
本文介绍了当我想要进入下拉菜单的主页时,为什么我的导航链接无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试单击产品(这样的导航栏:主页|产品|关于|联系人)时,它实际上并不链接到产品页面,只是作为悬停点,所以牛的下拉菜单和干草出现。我仍然希望有一个通用产品页面,然后是下拉菜单中的特定页面。



这是我的代码,请帮忙!



When I try to click "Products" (Nav Bar like this: Home | Products | About | Contact) it doesn't actually link to the products page, just acts as a hover spot so the dropdown menu of "Cattle" and "Hay" appear. I would still like there to be a general product page, then the specific pages from the dropdown menu as well.

Here's my code, please help!

<li class="nav-item dropdown">
                <a class="nav-link active dropdown-toggle" href="products.html" id="dropdown04" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Products</a>
                <div class="dropdown-menu" aria-labelledby="dropdown04">
                  <a class="dropdown-item" href="cattle.html">Cattle</a>
                  <a class="dropdown-item" href="hay.html">Hay</a>
                  </div>
              </li>





我的尝试:



我试图改变< a class tag但不知道该怎么做。



What I have tried:

I've tried to change the <a class tag but not sure what to do.

推荐答案

添加<$ c链接的$ c> data-toggle =dropdown可确保在您点击链接时显示下拉菜单。它会阻止浏览器跟踪链接,因为这会阻止您看到下拉菜单。



最简单的解决方案是将链接添加到下拉菜单中:

Adding data-toggle="dropdown" to the link ensures that the dropdown menu appears when you click the link. It prevents the browser from following the link, since this would prevent you from seeing the dropdown menu.

The simplest solution is to add the link to the dropdown menu as well:
<li class="nav-item dropdown">
    <a class="nav-link active dropdown-toggle" href="products.html" id="dropdown04" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Products</a>
    <div class="dropdown-menu" aria-labelledby="dropdown04">
        <a class="dropdown-item" href="products.html">All products</a>
        <a class="dropdown-item" href="cattle.html">Cattle</a>
        <a class="dropdown-item" href="hay.html">Hay</a>
    </div>
</li>


这篇关于当我想要进入下拉菜单的主页时,为什么我的导航链接无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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