问题
You can see my entire HTML here. You can copy/paste it into a demo document locally and see what I'm referring to.
http://chopapp.com/#ny9fxmtv
Basically I want to style the boxes to have both a gradient AND a custom arrow on the right. It's shown in the image above.
The problem is that the gradient I am getting is via this code:
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#ececec)) ;
This is line 21 in my code above. But because the "background" attribute is already taken up by this line, I cannot also include a "url(image.png)" tag to specify the custom down-arrow image, which is line 20 in my code.
Is there a way I can have gradient and a down-arrow image?
Thanks!
回答1:
Check this link
background: #6cab26;
background: url(IMAGE_URL); /* fallback */
background: url(IMAGE_URL), -webkit-gradient(linear, left top, left bottom, from(#444444), to(#999999)); /* Saf4+, Chrome */
background: url(IMAGE_URL), -webkit-linear-gradient(top, #444444, #999999); /* Chrome 10+, Saf5.1+ */
background: url(IMAGE_URL), -moz-linear-gradient(top, #444444, #999999); /* FF3.6+ */
background: url(IMAGE_URL), -ms-linear-gradient(top, #444444, #999999); /* IE10 */
background: url(IMAGE_URL), -o-linear-gradient(top, #444444, #999999); /* Opera 11.10+ */
background: url(IMAGE_URL), linear-gradient(top, #444444, #999999); /* W3C */
回答2:
<div class="selectParent">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
.selectParent{
width:80px;
overflow:hidden;
background: #d0e4f7;
background: -moz-linear-gradient(top, #d0e4f7 0%, #73b1e7 24%, #0a77d5 50%, #539fe1 79%, #87bcea 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d0e4f7), color-stop(24%,#73b1e7), color-stop(50%,#0a77d5), color-stop(79%,#539fe1), color-stop(100%,#87bcea));
background: -webkit-linear-gradient(top, #d0e4f7 0%,#73b1e7 24%,#0a77d5 50%,#539fe1 79%,#87bcea 100%);
background: -o-linear-gradient(top, #d0e4f7 0%,#73b1e7 24%,#0a77d5 50%,#539fe1 79%,#87bcea 100%);
background: -ms-linear-gradient(top, #d0e4f7 0%,#73b1e7 24%,#0a77d5 50%,#539fe1 79%,#87bcea 100%);
background: linear-gradient(to bottom, #d0e4f7 0%,#73b1e7 24%,#0a77d5 50%,#539fe1 79%,#87bcea 100%);
}
.selectParent select{
width: 100px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 2px 2px 2px 2px;
border: none;
background: transparent url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png") no-repeat 60px center;
}
DEMO
回答3:
could you use a list in the boxes with
ul.className {list-style-image:url('someimage.gif');}
and then put your box background as you wish.
Second option is just to place a div in top of that div and have one with the gradient and the top one with the arrow. something like that?
来源:https://stackoverflow.com/questions/12690754/styling-select-option-tags-with-gradient-and-custom-arrow