简体   繁体   English

如何在最小化浏览器中制作右侧和左侧导航栏子菜单

[英]how to make submenus of navigation bar on right side and on left side on minimization of browser

右侧的子菜单可以在导航栏中轻松实现,但是在最小化屏幕的情况下,如何使子菜单在左侧自动打开?

Here you are: 这个给你:

 @media screen and (min-width: 768px) { #mainmenu{ float: right; } } 
 <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Case</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container" align="right"> <ul id="mainmenu" class="nav nav-tabs"> <li class="dropdown"> <a class="dropdown-toggle navbar-right" data-toggle="dropdown" href="#">Menu 1 <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">Submenu 1-1</a></li> <li><a href="#">Submenu 1-2</a></li> <li><a href="#">Submenu 1-3</a></li> </ul> </li> </ul> </div> </body> </html> 

@media screen and (min-width: 500px) {
    .submenu {
        /*This and this style when window-width is greater than 500px*/
    }
    }

@media screen and (max-width: 500px) {
    .submenu {
        /*This and this style when window-width is less than 500px*/
    }
    }

Please add your current style and html-code for more detailed answer. 请添加您当前的样式和html代码以获取更详细的答案。

Try something like this: 尝试这样的事情:

nav li {
  float: right;
}

/*The max width the that the screen has to be for this rule to apply*/
@media only screen and (max-width: 900px) { 
  nav li {
    float: left;
  }
}

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

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