【问题标题】:Styling the typeahead.js list (the bootstrap way)样式化 typeahead.js 列表(引导方式)
【发布时间】:2014-07-11 08:56:11
【问题描述】:

我正在尝试使用 typeahead.js 创建一个自动完成文本字段。示例here 显示了格式良好的建议列表。但是,当我使用相同的代码时,我只会得到一个平淡无奇的建议列表,如下所示:

请查看jsFiddle 获取代码。

我正在使用Bootstrap。我需要做什么才能获得格式为Bootstrap 方式的列表?

【问题讨论】:

    标签: javascript twitter-bootstrap typeahead.js twitter-typeahead


    【解决方案1】:

    看起来默认输出根本没有样式,必须使用.tt 类来设置列表的样式。通过检查我想要的元素,我得到了以下代码,并根据您的需要进行调整。

    .tt-query,
    .tt-hint {
        width: 396px;
        height: 30px;
        padding: 8px 12px;
        font-size: 24px;
        line-height: 30px;
        border: 2px solid #ccc;
        border-radius: 8px;
        outline: none;
    }
    
    .tt-query {
        box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
    }
    
    .tt-hint {
        color: #999
    }
    
    .tt-dropdown-menu {
        width: 422px;
        margin-top: 12px;
        padding: 8px 0;
        background-color: #fff;
        border: 1px solid #ccc;
        border: 1px solid rgba(0, 0, 0, 0.2);
        border-radius: 8px;
        box-shadow: 0 5px 10px rgba(0,0,0,.2);
    }
    
    .tt-suggestion {
        padding: 3px 20px;
        font-size: 18px;
        line-height: 24px;
    }
    
    .tt-suggestion.tt-cursor {
        color: #fff;
        background-color: #0097cf;
    
    }
    
    .tt-suggestion p {
        margin: 0;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-20
      • 2012-05-26
      • 2014-02-10
      • 2017-06-12
      • 2021-08-16
      • 1970-01-01
      • 2013-11-05
      • 2012-12-29
      相关资源
      最近更新 更多