简体   繁体   English

如何创建垂直导航菜单?

[英]How to create a Vertical Navigation Menu?

Here is a menu using HTML and CSS. 这是使用HTML和CSS的菜单。 Menu items are placed horizontally and submenus use vertical layout. 菜单项水平放置,子菜单使用垂直布局。 How should main menu items be changed to be layed out vertically too? 如何将主菜单项也更改为垂直布局?

<ul>
  <li>
    <a>item1</a>
    <ul>
      <li><a>subitem1</a></li>
      <li><a>subitem1</a></li>
      <li><a>subitem1</a></li>
    </ul>
  </li>
</ul>

You have to do some minor changes and it will work as vertical. 您必须进行一些细微的更改,它将垂直运行。 and as you looking some more style to add on it you can do it easily. 当您寻找更多样式添加时,就可以轻松完成。

Check this fiddle CLICK HERE 点击这里查看小提琴

#menu
{
    width: 120px;/*change width*/
}
#menu li
{

    display: block; /*keep it block*/
    }
#menu ul
{

    top: 0; /*change this */
    left: 100%; /*change this */
}
#menu ul li:first-child > a:after
{
    content: '';
    position: absolute;
    left:-13px; /* change this*/
    top:7px; /* change this*/
    width: 0;
    height: 0;
    border: 5px solid transparent; /* change this*/
    /*border-right: 5px solid transparent;*/ /*don't need this*/
    border-right: 8px solid #444; /* change this*/
}

#menu ul li:first-child a:hover:after
{
    border-right-color: #04acec;  /* change this*/
}

I wrote in comments what to change specific to achieve what you want. 我在评论中写了具体更改以实现所需的内容。 You can manipulate more 您可以操纵更多

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

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