Solved

CSS dropdown select option:  styling WITHIN option text

Posted on 2015-01-06
3
249 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
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…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…

919 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now