选择框

时间:2015-10-27 12:28:53

标签: javascript html css

enter image description here

正如您在图像上看到的,我在选择框中有7个选项。是否可以在一个<option>或渐变背景中制作2个div。我需要在一个<option>中获得2种颜色。

<td class="footable-visible"  style="width:1px; ">
        <div class="container" style="width:130px;">                                            
            <div class="row">
                 <select id="mySelect"  class="form-control">
                    <option style="color:white;background-color:#72D527;"> </option>
                    <option style="color:white;background-color:#4DB6AC;"> </option>
                    <option style="color:white;background-color:#CE93D8;"> </option>
                    <option style="color:white;background-color:#FFAB91;"> </option>
                    <option style="color:white;background-color:#F9A825;"> </option>
                    <option style="color:white;background-color:#BCAAA4;"> </option>
                    <option style="color:white;background-color:#9E9E9E;"> </option>
                 </select> 
            </div>
        </div>
</td>

http://jsfiddle.net/9c6oca5q/

编辑:Gradient在Firefox中运行,但在Chrome中不运行

enter image description here enter image description here

1. Firefox                2. Chrome

2 个答案:

答案 0 :(得分:2)

你需要一个渐变:

.test{
    background-image: linear-gradient(blue 50%, green 50%);
}

DEMO

答案 1 :(得分:1)

这是你的代码:

<td class="footable-visible"  style="width:1px; ">
    <div class="container"  style="width:130px;">                                            
        <div class="row">
             <select id="mySelect"  class="form-control">
                <option style="color:white; background: -webkit-linear-gradient(#72D527, #C7EDC6); background: -o-linear-gradient(#72D527, #C7EDC6); background: -moz-linear-gradient(#72D527, #C7EDC6); background: linear-gradient(#72D527, #C7EDC6); "> </option>
                <option style="color:white;background-color:#4DB6AC;"> </option>
                <option style="color:white;background-color:#CE93D8;"> </option>
                <option style="color:white;background-color:#FFAB91;"> </option>
                <option style="color:white;background-color:#F9A825;"> </option>
                <option style="color:white;background-color:#BCAAA4;"> </option>
                <option style="color:white;background-color:#9E9E9E;"> </option>
             </select> 
        </div>
    </div>