2012-11-07 39 views
1

我不是一個Web開發人員的任何想象力,我得到的東西,我希望他們基本上通過審判和大量的錯誤的方式。我似乎無法弄清楚這一點。 我想改變我的下拉選擇器的風格,從使用默認的操作系統樣式到我找到的合適的樣式,但我無法弄清楚什麼去了哪裏。 這裏是我現有的下拉選擇CSS:css的下拉選擇器

/* select 
    ==========================================================*/ 
.selector, .selector * { 
/* margin: 0; 
    padding: 0; */ 
} 
.selector select:focus { outline: 0; } 

div.selector { 
/* background-position: -490px -24px; 
    display: inline-block; 
    overflow: hidden; 
    padding-left: 2px; 
    position: relative; 
    vertical-align: middle; 

    -webkit-border-radius: 3px; 
    -moz-border-radius: 3px; 
    border-radius: 3px; 

    -webkit-box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, 0.2); 
    -moz-box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, 0.2); 
    box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, 0.2); */ 
} 
    div.selector span { 
/* background-position: 100% 0; 
    color: #fff; 
    font-size: 11px; 
    font-weight: bold; 
    overflow: hidden; 
    padding: 0px 27px 0px 7px; 
    text-overflow: ellipsis; 
    text-shadow: 1px 1px 0 #000; 
    white-space: nowrap; */ 
    } 
    div.selector select { 
    /*background: #fff; 
    color: #000; 
    border: none; 
    left: 0; 
    opacity: 0; 
    position: absolute; 
    top: 0; 
    width: 100%; 
    text-transform:none;*/ 
    font-size:12px; 
    opacity: 1 !important; 
    } 

div.selector, div.selector span { 

    /*background-repeat: no-repeat; 
    line-height: 24px; 
    text-transform: uppercase; 
    background-image: url("sprite.png"); 
    background-repeat: no-repeat; 
    line-height: 24px;*/ 

} 
div.selector, div.selector span, div.selector select { /*height: 24px;*/  } 
/* #sort { 

    margin: 10px 0; 
    float:right; 
    width:257px; 
} 
#sort span {display:none;} 
#sort SELECT { 
    background: none repeat scroll 0 0 #fff; 
    color: #000; 
    vertical-align: bottom; 
    opacity:1 !important; 
    float:left; 

} */ 

button, textarea, input[type=text], input[type=password] { 
    border: 0; 
    margin: 0; 
    padding: 0; 
} 

textarea, input[type=text], input[type=password], select, .selector span { 
    color: #888; 
    font: 12px 'Helvetica Neue', Arial, sans-serif; 
} 

input[type=submit] { font: 12px 'Helvetica Neue', Arial, sans-serif; } 

textarea, input[type=text], input[type=password] { 
    border: 1px solid #a9a9a9; 
    padding: 4px 8px; 

} 

button { 
    background: transparent; 
    color: #1b1e00; 
    font-size: 28px; 
    text-transform: lowercase; 
} 

button, label, input[type=submit] { cursor: pointer; } 



.selector span { display: block; } 
.selector, .selector span, .selector select { cursor: pointer; } 

這裏是因爲我想它是什麼樣子的CSS:

/* all form DIVs have position property set to relative so we can easily position newly created SPAN */ 
form div{position:relative;} 

/* setting the width and height of the SELECT element to match the replacing graphics */ 
select.select{ 
    position:relative; 
    z-index:10; 
    width:166px !important; 
    height:26px !important; 
    line-height:26px; 
} 

/* dynamically created SPAN, placed below the SELECT */ 
span.select{ 
    position:absolute; 
    bottom:0; 
    float:left; 
    left:0; 
    width:166px; 
    height:26px; 
    line-height:26px; 
    text-indent:10px; 
    background:url(images/bg_select.gif) no-repeat 0 0; 
    cursor:default; 
    z-index:1; 
    } 

基本上我不知道在哪裏都行。任何幫助將非常感激。

謝謝!

+2

添加jsfiddle會很有幫助。 – thedjpetersen

回答

0

現在唯一完全支持下拉菜單樣式的瀏覽器是chrome。看到這篇文章:
How to style a <select> dropdown with CSS only without JavaScript?

如果你需要你的下拉菜單來匹配跨瀏覽器有幾個選項。
1)http://harvesthq.github.com/chosen/或其他喜歡它(我通常選擇),
2)從頭開始重新設計一個下拉菜單。不建議這樣做,因爲它非常複雜並且容易產生錯誤。見http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspx

http://css-tricks.com/dropdown-default-styling/

希望這有助於!