jquery - 无法获得 jquery 自动完成样式

标签 jquery css jquery-ui themes

我在测试页面上使用了 jquery 自动完成示例,但似乎无法设置下拉列表的样式。它只是显示为带有 li 项的普通 ul(不是示例中带有列表的白色背景框)。我已经单独尝试过这个,并且使用 redmond 主题,对我可能做错了什么有什么想法吗?我在 firebug 中看到了 redmond 样式表,所以页面正在加载它们。

js(工作)

$(document).ready(function() {
    $("input").autocomplete({
        source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
    });
});

css/js 包含

<script src="/public/javascripts/jquery-1.6.2.js'"></script>
<script src="/public/javascripts/jquery-ui-1.8.14.custom.min.js"></script>
<script src="/public/javascripts/ac.js"></script> // where the above js is 
<script src="/public/javascripts/jquery.tools.min.js"></script>

<link rel="stylesheet" type="text/css" media="print" href="/public/stylesheets/redmond/jquery.ui.all.css"/>

这里是输入:

<input name="searchString" type="text" class="searchbox ui-autocomplete" id="autocomplete"/>

(编辑:添加了 CSS,写问题时忽略了这一点)

最佳答案

下载主题并包含主题的 CSS。

<link rel="stylesheet" href="/public/css/jquery-ui.css" type="text/css">

可以看到主题here , 然后从 download page 下载它们通过在右侧栏中选择您想要的主题..

编辑:看起来您正在使用旧的 jQuery auto-complete plug-in已停产。如果您愿意,可以尝试使用以下 CSS。不过,我强烈建议您使用 jQuery UI 自动完成功能。

/* Autocomplete styles */
.ac_results {
        padding: 0px;
        border: 1px solid black;
        background-color: white;
        overflow: hidden;
        z-index: 99999;
}

.ac_results ul {
        width: 100%;
        list-style-position: outside;
        list-style: none;
        padding: 0;
        margin: 0;
}

.ac_results li {
        margin: 0px;
        padding: 2px 5px;
        cursor: default;
        display: block;
        /*
        if width will be 100% horizontal scrollbar will apear
        when scroll mode will be used
        */
        /*width: 100%;*/
        font: menu;
        font-size: 12px;
        /*
        it is very important, if line-height not setted or setted
        in relative units scroll will be broken in firefox
        */
        line-height: 16px;
        overflow: hidden;
}

.ac_loading {
        /* loader image */
        background: white url('indicator.gif') right center no-repeat;
}

.ac_odd {
        background-color: #eee;
}

.ac_over {
        background-color: #0A246A;
        color: white;
}

关于jquery - 无法获得 jquery 自动完成样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6618175/

相关文章:

javascript - 如何确保在执行脚本之前包含某些库?

jquery - 有没有一个 jquery 插件可以显示类似微软向导的东西?

javascript - 如何修改 jQuery Cycle 插件的渲染?

html - 名片图片放大过大

javascript - 过渡事件在高度过渡时触发得太早

javascript - 将 jQuery UI 自动完成下拉菜单的位置降低 20 像素

javascript - JSONP 不起作用?

jquery - 超出其 DIV 指定宽度的文本

css - jQuery Mobile 复选框保持登录状态

javascript - Jquery UI "drop"效果 - 背景移动