HTML and CSS caret dropdown menu

核能气质少年 提交于 2021-01-29 14:25:08

问题


how can one add a dropdown caret to the account link in the html code below . . .

<nav>
    <ul id="menu">
        <li class="home"><a href= "home.html" class="menu" ><h3>Home</h3></a></li>
        
        <li class="news"><a href= "news.html" class="menu" target="_blank"><h3>News</h3></a></li>
        
        <li class="account"><a href= "#"  class="menu dropdown-toggle" target="_blank" data-toggle="dropdown"><h3>Account</h3></a></li> 
   </ul>  
    </nav>  

回答1:


There are many ways to do this. Here is a way using only CSS and the ::after psuedo element.

.dropdown-toggle {
  display: flex;
  align-items: center;
}

.dropdown-toggle::after {
  content: "⬇️";
  margin-left: 10px;
}
<nav>
  <ul id="menu">
    <li class="home"><a href="home.html" class="menu">
        <h3>Home</h3>
      </a></li>

    <li class="news"><a href="news.html" class="menu" target="_blank">
        <h3>News</h3>
      </a></li>

    <li class="account"><a href="#" class="menu dropdown-toggle" target="_blank" data-toggle="dropdown">
        <h3>Account</h3>
      </a></li>
  </ul>
</nav>


来源:https://stackoverflow.com/questions/62844114/html-and-css-caret-dropdown-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!