简体   繁体   English

如何在不破坏代码的情况下向可折叠侧边栏菜单添加可点击链接?

[英]How can I add a clickable link to my collapsable sidebar menu without breaking my code?

Currently trying to make a sidebar on HTML/CSS however I am struggling to finalise it by adding clickable links for navigating around my site.目前正试图在 HTML/CSS 上制作一个侧边栏,但是我正在努力通过添加可点击的链接来在我的网站上导航来完成它。

I believe it is a simple CSS issue or a simple HTML problem but it's driving me crazy!我相信这是一个简单的 CSS 问题或一个简单的 HTML 问题,但这让我发疯!

                    <li class="c-menu__item has-submenu" title="Account">
                        <div class="c-menu__item__inner"><i class="fa fa-cog"></i>
                            <div class="c-menu-item__title"><a href="accountdetails.php"
                                    style="text-decoration: none"><span>Account Settings</span></div></a>
                        </div>

Is what I have at the moment but there are two problems, I cannot click the button when the sidebar is collapsed, nor can I click the div the text/icon are present in, I must only click the text to get it to work.是我目前所拥有的,但有两个问题,当侧边栏折叠时我无法单击按钮,也无法单击文本/图标所在的 div,我只能单击文本才能使其工作。

Preferably I would like to click the box the icon, text are held in for easier usage.最好我想单击图标框,将文本保留在其中以便于使用。

How can I achieve this instead of just text being hyperlinked?我怎样才能做到这一点,而不仅仅是文本被超链接?

Photo showing the area I would like clickable on sidebar opposed to just the text.照片显示了我希望在侧边栏上可点击的区域,而不仅仅是文本。

This is because your anchor tag is wrapping only the text "Account settings".这是因为您的锚标记仅包含文本“帐户设置”。 You should place your anchor tag in a way that wraps the elements that you want them to work like a link.您应该以一种包装您希望它们像链接一样工作的元素的方式放置您的锚标记。

Also be aware that in the code you shared, you closed a div before closing the anchor tag, and you are not closing the list item tag.另请注意,在您共享的代码中,您在关闭锚标记之前关闭了一个 div,并且您没有关闭列表项标记。

Try like this:试试这样:

<li class="c-menu__item has-submenu" title="Account" >
    <a href="accountdetails.php" style="text-decoration: none">
        <div class="c-menu__item__inner">
            <i class="fa fa-cog"></i>
            <div class="c-menu-item__title">
                <span>Account Settings</span>
            </div>
        </div>
    </a>
</li>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM