customizing the drop down autocomplete box
Asked Answered
A

6

5

I'm using jquerys autocomplete widget but I'm having a few issues trying to style the box that drop down when you search for something.

I'm trying to move the box down a bit and change the border/bg color but some JS is adding in some embedded styles which are overriding my .css styles. But I can't find it.

I'v based mine off this one.

<ul class="ui-autocomplete ui-menu ui-widget-content" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 11; display: block; width: 139px; top: 44px; left: 1101px; "><li class="ui-menu-item" role="menuitem">
Altruistic answered 6/12, 2011 at 3:41 Comment(1)
Some more of the code you are having trouble with would be helpful.Disinter
R
7

In order to avoid using !important you could add your styles with jQuery and override them in that way.

$('ul.ui-autocomplete').css({
    color: 'red'
});

Another solution would be to remove the style attribute from the ul.

$('ul.ui-autocomplete').removeAttr('style');
Roop answered 9/12, 2011 at 10:17 Comment(0)
C
4

Without seeing your css styles, or the order you are loading the .css files, you could override the styles by using Firebug to inspect which classes are applied, and adding !important; to your main css styles.

Ex.

ul.ui-autocomplete {
color: red !important;
}

The best way you can combat this is to properly track down if your jQuery plugin has any parameters to help you, or strip the JS yourself and add your own CSS styles.

The above !important; rule can be a nightmare, it is a hack in a sense - but it may work for you.

Caught answered 9/12, 2011 at 10:11 Comment(0)
N
2

Try to add margin-top and margin-left in your css

Overriding the top and left value is no good, because it is calculated in regard to the text field it derives from.

Noami answered 9/12, 2011 at 10:50 Comment(0)
P
2

I'm really not a pro in jquery but I take a look around in the example you sent and the style of the menu is all givent by a menu style sheet (jquery.ui.menu.css). Look at the link below and there is some info that can help you I think.

http://docs.jquery.com/UI/Menu#theming

You will be able to customize the look and feel of your dropdown in these class.

«If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.menu.css stylesheet that can be modified.» From jquery website.

Platitudinous answered 9/12, 2011 at 13:16 Comment(0)
F
2

try using position or append to option... you can refer here...

http://jqueryui.com/demos/autocomplete/#option-position

Figurate answered 10/12, 2011 at 5:11 Comment(0)
A
2

Check out the file jquery.ui.theme.css,

the class .ui-widget-content near the top can be used to put a background colour on the autocomplete search results box, borders and positioning can also be tweaked through this class.

Abreu answered 12/12, 2011 at 22:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.