Solved

CSS dropdown select option:  styling WITHIN option text

Posted on 2015-01-06
3
254 Views
Last Modified: 2015-01-06
i've found several CSS schemes that work for styling an HTML FORM dropdown menu
so that it uses a nice font and overall stylings.

However, for this project,  the option text label content has three components (columns)  that really could use some graphic delineation,
such as tab-like alignments ("columns") or at least  Bold and/or Color changes    in order to appear
somewhat organized and more readable.

For instance, here's a sample option label content:

6'x9'           FREE SHIPPING    -        US$587.00
7'6"x9'6"           FREE SHIPPING    -        US$778.00
8'x10'           FREE SHIPPING    -        US$873.00
18'6"x24'8"           SHIPPING CHARGES APPLY    -        US$1959.00

Even with several tries of CSS stylings found on the web,  there seems no way to align, etc.

it's database-generated (which in itself is no problem), (and easy to apply divs/spans/classes)
but i'm looking for some technique to apply a tidy formatting scheme.

I suppose i could revert to some sort of a flyout radio button scheme that collapses once selected, and
then the text could be aligned with CSS classes.  (but seems awfully awkward)

any thoughts/suggestions?

thanks!
0
Comment
Question by:willsherwood
3 Comments
 
LVL 25

Accepted Solution

by:
Kyle Hamilton earned 250 total points
ID: 40534823
you can't style select elements to that degree. So what people end up doing is scripting a solution which replaces the select dropdown with a list (ul), which can be styled to your heart's content. There are javascript libraries out there that simplify this.

Personally I would just use a ul to begin with, and forget about the select drop-down. You will need to pass the values to your form through javascript. There are a number of different ways to do that depending on how you are submitting the form.
0
 
LVL 4

Assisted Solution

by:Tom Chadaravicius
Tom Chadaravicius earned 250 total points
ID: 40534860
1. To second and augment what Kyle has said, you can have more freedom to style the surrounding element than the stubborn one ("text" appears stubborn.) I use <div> preceding text to accomplish that.
There may not be ul around the text but there's going to be <div> and body - the latter for sure.
2. All elements get set up in the "bootstrap" portion of the CSS - the very top of the first sheet.
input[type=text]{ (your style here) }
Chrome is especially sensible to that (but Chrome also has a quite extensive "Inspect Element" option to track where the style of an element is defined.)
0
 

Author Closing Comment

by:willsherwood
ID: 40534872
based on your excellent comments, i was able to search in this new direction and found this solution:
http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspx

thank you!
1

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question