Jump to content

Colour selection


rarebit

Recommended Posts

Hi,

I'm after putting a colour swatch within a combo, but it's eluding me. I can change the individual colours of the text, add images, but not a little swatch.

 

<select name='bg_col'>
<option value='#3cb878' selected><div style='width:5px;height:5px;background-color:#3cb878;'>X</div>#3cb878</option>
<option value='#4b0049'><div style='width:5px; height:5px; background-color:#4b0049;'>X</div>#4b0049</option>
<option value='#000000'><div style='width:5px; height:5px; background-color:#000000;'>X</div>#000000</option>
<option value='#ffffff'><div style='width:5px; height:5px; background-color:#ffffff;'>X</div>#ffffff</option>
</select>

 

Cheers for any solutions...

Link to comment
https://forums.phpfreaks.com/topic/139362-colour-selection/
Share on other sites

background:#fff; will suffice - you don't need to use background-color.

 

From what I know you are not getting any results because you are limited by the select and option tags. You're not able to style certain elements or elements within certain elements.

 

The only way around it is to have the swatches external of the option tags.

 

Hope that helps.

Link to comment
https://forums.phpfreaks.com/topic/139362-colour-selection/#findComment-729035
Share on other sites

Hey rarebit

 

I did have a thought about what you are trying to attempt.  I haven't tested it myself yet...but here we go.

 

You know if the small bit of text on the left was the same size you could create a background image for each option and utilize a class or id on the option tag while still accomplishing what you want.

 

Downside:  If the width varies...well you get the picture.

 

 

So something like this can still work:

 

.option1 { background-image: images/image1.jpg; other css }

.option2 { background-image: images/image2.jpg; other css }

 

....

<select>

  <option class="option1">Test 1</option>

  <option class="option2">Test 2</option>

</select>

 

 

Link to comment
https://forums.phpfreaks.com/topic/139362-colour-selection/#findComment-729171
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.