Solved

CSS dropdown select option:  styling WITHIN option text

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

743 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

9 Experts available now in Live!

Get 1:1 Help Now