2012-11-09 80 views
1

在我的PHP系統中,人們可以選擇一種顏色組合。我與一個選項列表中選擇這樣做的:html/css 2種顏色1選項選擇列表

<style> 
    OPTION.purple{ width: 100px; background-color: #1d5280; color:white} 
    OPTION.green{ width: 100px; background-color: #30843b; color:white} 
</style> 
<select> 
    <option>Choose color</option> 
    <option class="purple">Purle/Blue</option> 
    <option class="green">Brown/Green</option> 
</select> 

現在,每個選項都有1點的顏色,是可以給予1種選擇2種顏色。所以選項的前半部分有1種顏色,另一半選項有另一種顏色。

+0

我不認爲你可以爲'option'做這件事,你可以爲'div'元素做這樣的事情。 – freebird

+2

你不能添加背景圖片,這是50:50 – Michael

回答

1

純CSS沒有圖像,我認爲你不能這樣做。我建議你使用圖像。

LIVE DEMO

我用線性漸變在此演示(:變化與-webkit-linear-gradient如果-moz-linear-gradient您正在使用FF或-o-linear-gradient如果你正在使用Opera)。它適用於div元素,但不能應用於選項背景(請參閱演示)。

2

您可以使用SCSS來做到這一點。這裏網站教你所有的事情。
--otherwise
如果使用不同的顏色差異類指

OPTION.purple{ width: 100px; background-color: #1d5280; color: white;} 
OPTION.green{ width: 100px; background-color: #30843b; color: red;} 

或u使用相同的顏色意味着

OPTION.purple{ width: 100px; background-color: #1d5280;} 
OPTION.green{ width: 100px; background-color: #30843b;} 
option.green, option.purple {color: white;} 

<style> 
    OPTION.purple{ width: 100px; background-color: #1d5280; } 
    OPTION.green{ width: 100px; background-color: #30843b;} 
    option.add {color: white} 
</style> 
<select> 
    <option>Choose color</option> 
    <option class="purple add">Purle/Blue</option> 
    <option class="green add">Brown/Green</option> 
</select> 
+0

這不是OP想要的,他要求一個選項兩種顏色。 – freebird

+0

謝謝你的回答,但那不完全是我的意思。我的意思是背景色是50/50其他顏色。 – Marnix

+0

編輯了一些東西供您參考。 – Selvamani