twitter-bootstrap 带有自定义内容的 Bootstrap 按钮下拉菜单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25424163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 21:21:56  来源:igfitidea点击:

Bootstrap button dropdown with custom content

twitter-bootstraptwitter-bootstrap-3

提问by SiberianGuy

I'd like to use Bootstrap's button dropdownto display a form component instead of a list of other buttons with additional information. Is it possible?

我想使用 Bootstrap 的按钮下拉菜单来显示表单组件,而不是带有附加信息的其他按钮列表。是否可以?

回答by Jordan.J.D

Yes, this is possible by replacing the usual <li><a>text</a></li>that is inside the button dropdown with <li>[form code] </li>; I have added a form into a dropdown like so;

是的,这可以通过将<li><a>text</a></li>按钮下拉菜单中的常用替换为<li>[form code] </li>; 我在下拉菜单中添加了一个表单;

Code:

代码:

<div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Click for form <span class="caret"></span>

    </button>
    <ul class="dropdown-menu" role="menu">
        <li>
          <div class="container">
            <div class="form-group">
                <label label-default="" for="exampleInputEmail1">Email address</label>
                <input type="email" class="form-control" id="exampleInputEmail1"
                placeholder="Enter email">
            </div>
            <div class="form-group">
                <label label-default="" for="exampleInputPassword1">Password</label>
                <input type="password" class="form-control" id="exampleInputPassword1"
                placeholder="Password">
            </div>
            <div class="form-group">
                <label label-default="" for="exampleInputFile">File input</label>
                <input type="file" id="exampleInputFile">
                <p class="help-block">Example block-level help text here.</p>
            </div>
            <div class="checkbox">
                <label>
                    <input type="checkbox">Check me out</label>
            </div>
            <button type="submit" class="btn btn-default">Submit</button>
            </div>
        </li>
    </ul>
</div>

Preview:

预览:

bootstrap button drop down with form

带表单的引导按钮下拉菜单

DEMO

演示