twitter-bootstrap - 向 Twitter bootstrap typeahead 组件添加下拉按钮

标签 twitter-bootstrap

Twitter bootstrap 带有一个非常方便的类似自动完成的组件,称为 typeahead。我正在尝试添加一个小的下拉按钮(或小部件),这样当按下 typeahead 组件时,它就像一个普通的下拉选择器,显示所有可用的数据源绑定(bind)选项(除了它的 native 自动完成功能)。当前标记类似于以下内容:

<input type="text" 
       data-provide="typeahead"
       data-items=5
       data-source='["option 1","option 2","option 3"]'>

因此,实际上需要让组件充当下拉和自动完成小部件的混合体。
以前有人做过吗?谢谢...

最佳答案

我发现了这个出色的组件:

Source code
Live example

不过有一件事,下拉按钮的背景在翻转时看起来很有趣。该修复涉及“bootstrap-combobox.css”中的一个小改动:

...
.combobox-container .add-on {
    float: left;
    display: block;
    width: auto;
    min-width: 16px;
    height: 18px;
    margin-right: -1px;
    padding: 4px 5px;
    font-weight: normal;
    line-height: 18px;
    color: #999999;
    text-align: center;
    text-shadow: 0 1px 0 #ffffff;
    /*   background-color: #f5f5f5; */ // <<------------ comment this line
    border: 1px solid #ccc;
    -webkit-border-radius: 3px 0 0 3px;
    -moz-border-radius: 3px 0 0 3px;
    border-radius: 3px 0 0 3px;
}
...

关于twitter-bootstrap - 向 Twitter bootstrap typeahead 组件添加下拉按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10689830/

相关文章:

css - 将背景图像保持在相对于标题的恒定高度

css - 按高度将页面分成多个部分,部分未扩展到指定的完整高度

javascript - 将 PHP 值传递给 Twitter Bootstrap 模式

html - 如何修复按钮,使其不会因相邻元素的影响而改变其位置?

html - Bootstrap 3 背景图像多个部分

twitter-bootstrap - Bootstrap 5 引用错误 : bootstrap is not defined

javascript - 如何更新使用 jQuery 启动的模式中的 -data-row 属性?

html - 如何让 bootstrap col-sm-* 在移动设备上工作?

html - 如何在 bootstrap 4 按钮中垂直居中文本?

html - 如何将品牌、链接和 facebook 链接放在同一行? Bootstrap 3