自定义boostrap下拉列表出现问题

时间:2015-07-30 20:42:33

标签: twitter-bootstrap dropdownbox

I have a fiddle that doesn't work

我正在尝试使用输入列表和某些功能按钮创建“下拉”类型效果。基本上,有一个表,然后是一个包含6个输入的列表,可以过滤此表上的结果。我有完整的视图和正常工作(虽然我删除了我的小提琴的功能)。

我知道我需要使用

的一般布局
<ul>
   <li>
      <div>
          <input/>
      <div>
   </li>
   <li>
      <div>
          <input/>
      </div>
   </li>
</ul>

因为<div>不能直接进入<ul>

我做错了什么?

link to what i want to see after my dropdown is clicked

2 个答案:

答案 0 :(得分:1)

这可能会有所帮助。

&#13;
&#13;
.menu-large {
  position: static !important;
  text-align: center;
}
.megamenu {
  padding: 20px 0px;
  width: 100%;
  border: none;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default">
  <a class="navbar-brand" href="#">
    <img alt="Brand" src="http://placehold.it/15x15/f00" />
  </a>
  <a class="navbar-brand pull-right" href="#">
    <img alt="Brand" src="http://placehold.it/15x15/f00" />
  </a>

  <div class="navbar-collapse">
    <ul class="nav navbar-nav">
      <li class="dropdown menu-large"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Stuff <span class="caret"></span></a>

        <ul class="dropdown-menu megamenu">
          <li>
            <div class="col-lg-12">
              <form>
                <div class="row">
                  <div class="col-sm-3">
                    <div class="form-group">
                      <input type="text" class="form-control" id="input1" placeholder="Input" />
                    </div>
                  </div>
                  <div class="col-md-3">
                    <div class="form-group">
                      <input type="text" class="form-control" id="input2" placeholder="Input" />
                    </div>
                  </div>
                  <div class="col-md-3">
                    <div class="form-group">
                      <input type="text" class="form-control" id="input3" placeholder="Input" />
                    </div>
                  </div>
                  <div class="col-md-3">
                    <div class="form-group">
                      <input type="text" class="form-control" id="input4" placeholder="Input" />
                    </div>
                  </div>
                </div>
                <div class="row">
                  <div class="col-md-4">
                    <div class="form-group">
                      <select class="form-control">
                        <option value="1">Option 1</option>
                        <option value="2">Option 2</option>
                      </select>
                    </div>
                  </div>
                  <div class="col-md-4">
                    <div class="form-group">
                      <select class="form-control">
                        <option value="1">Option 1</option>
                        <option value="2">Option 2</option>
                      </select>
                    </div>
                  </div>
                  <div class="col-md-4">
                    <div class="form-group">
                      <button type="button" class="btn btn-sm-update btn-primary ">UPDATE</button>
                      <button type="button" class="btn btn-sm-x btn-default transparent glyphicon glyphicon-remove"></button>
                    </div>
                  </div>
                </div>
              </form>
            </div>
          </li>
        </ul>
      </li>
    </ul>
  </div>
</nav>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

this怎么样?

<div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action</button>
    <div class="dropdown-menu">
        <!-- dropdown content -->
    </div>
</div>

当然,您可以将dropdown-menu的宽度设置为您想要的任何宽度。