Bootstrap3下拉菜单对齐

时间:2014-08-04 18:23:21

标签: html css twitter-bootstrap-3

我正在为我的项目使用bootstrap3,并在我的工具栏中添加了一个大型菜单,我在一个片段网站上找到了。

当我添加菜单时,我试图让它在按钮下面对齐,但是它向右移动。

我尝试了这个,但它没有改变任何东西。

.dropdown-large{ left:inherit }

如果需要,可以在此处找到示例代码:http://bootsnipp.com/snippets/featured/large-dropdown-menu

enter image description here

这是菜单背后的CSS:

.dropdown-large {
  position: static !important;
}
.dropdown-menu-large {
  margin-left: 16px;
  margin-right: 16px;
  padding: 20px 0px;
}
.dropdown-menu-large > li > ul {
  padding: 0;
  margin: 0;
}
.dropdown-menu-large > li > ul > li {
  list-style: none;
}
.dropdown-menu-large > li > ul > li > a {
  display: block;
  padding: 3px 20px;
  clear: both;
  font-weight: normal;
  line-height: 1.428571429;
  color: #333333;
  white-space: normal;
}
.dropdown-menu-large > li ul > li > a:hover,
.dropdown-menu-large > li ul > li > a:focus {
  text-decoration: none;
  color: #262626;
  background-color: #f5f5f5;
}
.dropdown-menu-large .disabled > a,
.dropdown-menu-large .disabled > a:hover,
.dropdown-menu-large .disabled > a:focus {
  color: #999999;
}
.dropdown-menu-large .disabled > a:hover,
.dropdown-menu-large .disabled > a:focus {
  text-decoration: none;
  background-color: transparent;
  background-image: none;
  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  cursor: not-allowed;
}
.dropdown-menu-large .dropdown-header {
  color: #428bca;
  font-size: 18px;
}
@media (max-width: 768px) {
  .dropdown-menu-large {
    margin-left: 0 ;
    margin-right: 0 ;
  }
  .dropdown-menu-large > li {
    margin-bottom: 30px;
  }
  .dropdown-menu-large > li:last-child {
    margin-bottom: 0;
  }
  .dropdown-menu-large .dropdown-header {
    padding: 3px 15px !important;
  }
}

我怎样才能将该菜单更多地移动?

更新:这是一个问题的小提琴。拖动窗口要大;您将看到它是如何在页面右侧的静态位置。 http://jsfiddle.net/MV9tL/embedded/result/

1 个答案:

答案 0 :(得分:0)

我能想到的唯一不会弄乱其他功能的是:

DEMO:http://jsbin.com/raxuli/1

不要使用!重要,在媒体查询之外更具体:

.dropdown.dropdown-large {
  position: static;
}

添加到您的CSS结尾:

@media (min-width: 1300px) { 
    .dropdown-menu-large {
        min-width: 600px; /*needs a width or add width to the stuff inside it */
    }

    .navbar-nav .dropdown.dropdown-large {
        position: relative
    }
}