简体   繁体   English

jquery自动完成风格

[英]jquery auto complete style

    $(document).ready(function () {
        $("#staff").autocomplete({
            source: "/classname/methodname",
            minLength: 1,
            typeAhead: true,
            select: function (event, ui) {
            }
        })
            .data("ui-autocomplete")._renderItem = function (ul, x) {
                return $("<li>")
                  .append("<a>" + x.StaffFullName + " " + x.Department + " </a>")
                  .appendTo(ul);
            };
    });

I am using MVC to design my website, I am using autocomplete to find the names of staff who are working in a company. 我正在使用MVC来设计我的网站,我正在使用自动填充来查找在公司工作的员工的姓名。 When I run the website I get staff fullname followed by the department. 当我运行网站时,我得到员工姓名,然后是部门。 I want 3d affect. 我想要3D影响。 So i want a black thin line box around the results and when you hoverover a staff name it should be grey colour as the original jquery website have. 所以我希望在结果周围有一个黑色细线框,当你悬停一个员工名字时,它应该是原始jquery网站的灰色。 Website also the width of my result is too large is there any way I can control it so that according to staff name width will expand. 网站也是我的结果的宽度太大有没有办法我可以控制它,以便根据员工名称宽度将扩大。

Yes you can change the width of the auto complete. 是的,您可以更改自动完成的宽度。
Inspect your element and find root div of auto-complete. 检查您的元素并找到自动完成的根div。
search for these classes: 搜索这些类:
"ui-autocomplete ui-front ui-menu ui-widget ui-widget-content ui-corner-all" “ui-autocomplete ui-front ui-menu ui-widget ui-widget-content ui-corner-all”

.ui-widget-content {
border: 1px solid #AAAAAA;
color: #222222;
} //for background color.

.ui-menu {
display: none;
left: 561px;
top: 477px;
width: 554px;
}// for div width

.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br {
border-bottom-right-radius: 4px;
}

.ui-menu .ui-menu-item a.ui-state-focus,
.ui-menu .ui-menu-item a.ui-state-active {
font-weight: normal;
margin: -1px;
background-color:#CCCCCC !important; 
}/**Color added for autocomplete hover on selected item**/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM