This example demonstrates the CSS applied to an implementation of the AutoComplete control that uses the "Sam Skin". You can read more about the general approach to skinning YUI components in this in-depth article. Change any or all of the skin and implementation CSS for a more customized look and feel.
In order to enable the new skinning model, AutoComplete expects a wrapper DIV element around the INPUT element and the container DIV element, in this fashion:
<div id="myAutoComplete"> <input type="text" id="myInput"> <div id="myContainer"></div> </div>
DOM Overview:
1 | <div id="autocomplete" class="yui-ac"> |
2 | <input id="input" type="text" class="yui-ac-input"> |
3 | <div id="container" class="yui-ac-container"> |
4 | <div class="yui-ac-content"> |
5 | <div class="yui-ac-hd"></div> |
6 | <div class="yui-ac-bd"> |
7 | <ul> |
8 | <li class="yui-ac-highlight"></li> |
9 | <li class="yui-ac-prehighlight"></li> |
10 | <li></li> |
11 | ... |
12 | </ul> |
13 | </div> |
14 | <div class="yui-ac-ft"></div> |
15 | </div> |
16 | <div class="yui-ac-shadow"></div> |
17 | <iframe></iframe> |
18 | </div> |
19 | </div> |
view plain | print | ? |
AutoComplete CSS:
1 | /* styles for entire widget */ |
2 | .yui-skin-sam .yui-ac { |
3 | position:relative;font-family:arial;font-size:100%; |
4 | } |
5 | |
6 | /* styles for input field */ |
7 | .yui-skin-sam .yui-ac-input { |
8 | position:absolute;width:100%; |
9 | } |
10 | |
11 | /* styles for results container */ |
12 | .yui-skin-sam .yui-ac-container { |
13 | position:absolute;top:1.6em;width:100%; |
14 | } |
15 | |
16 | /* styles for header/body/footer wrapper within container */ |
17 | .yui-skin-sam .yui-ac-content { |
18 | position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050; |
19 | } |
20 | |
21 | /* styles for container shadow */ |
22 | .yui-skin-sam .yui-ac-shadow { |
23 | position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity: 0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049; |
24 | } |
25 | |
26 | /* styles for results list */ |
27 | .yui-skin-sam .yui-ac-content ul{ |
28 | margin:0;padding:0;width:100%; |
29 | } |
30 | |
31 | /* styles for result item */ |
32 | .yui-skin-sam .yui-ac-content li { |
33 | margin:0;padding:2px 5px;cursor:default;white-space:nowrap; |
34 | } |
35 | |
36 | /* styles for prehighlighted result item */ |
37 | .yui-skin-sam .yui-ac-content li.yui-ac-prehighlight { |
38 | background:#B3D4FF; |
39 | } |
40 | |
41 | /* styles for highlighted result item */ |
42 | .yui-skin-sam .yui-ac-content li.yui-ac-highlight { |
43 | background:#426FD9;color:#FFF; |
44 | } |
view plain | print | ? |
Implementation CSS:
1 | /* styles for this implementation */ |
2 | #autocomplete { |
3 | width:15em; /* set width for widget here */ |
4 | padding-bottom:2em; |
5 | } |
view plain | print | ? |
Copyright © 2008 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings