Style Sheets
  Home arrow Style Sheets arrow Page 2 - An Easy Way to Build Replacement Combo Box...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

An Easy Way to Build Replacement Combo Boxes
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2007-04-09

    Table of Contents:
  • An Easy Way to Build Replacement Combo Boxes
  • Adding Some CSS
  • Styling the Text Input Field
  • Adding JavaScript

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    An Easy Way to Build Replacement Combo Boxes - Adding Some CSS


    (Page 2 of 4 )

    Let's add some CSS now to get it looking like a combo box. In a new file in your text editor, add the following code:

    .arrow {
      
    height:20px;
     
    border-style:solid;
     
    border-width:1px 1px 1px 1px;
     
    border-color:blue;
     
    margin:0px;
     
    padding:0px;
     
    vertical-align:bottom;
    }

    This selector targets the drop-down arrow image and ensures that it is the correct size and has no margins or padding. Although I haven't done so in this example, you could easily use CSS to specify a second arrow image that could be used as a rollover, just to reinforce to visitors that it will do something when clicked. I think however that the functionality of combo boxes has been around long enough to be ingrained in the mind of pretty much any visitor, so they should assume that it will work in the same way as a standard combo box. Most visitors hopefully will not even have to think about it and will just assume it is an actual combo box, which is after all the intention behind the article.

    Due to an inconsistency between IE and Firefox, the current code will line up the image correctly in FireFox, placing the image next to and inline with the text field. In IE however, the image is offset slightly. It's only a minor problem, but it does have an impact on how the page is viewed so should be corrected. We can do this with the following hack that targets IE 6 only:

    * html body img.arrow {
     
    position:relative;
     
    top:-1px;
    }

    This is a well established hack for targeting IE 6 only with additional rules, sometimes referred to as the star hack. Whatever it's called, it works well in situations like this, but only works with IE 6. IE 7 will still display the image incorrectly. There is still a way to target IE 7 though, use:

    *+ html body img.arrow {
     
    position:relative;
     
    top:-1px;
    }

    More Style Sheets Articles
    More By Dan Wellman


       · Hello All,This article shows a very quick and easy way to implement custom...
       · HiIs it my imagination or is there no example of what this replacement combo box...
       · Hi, I totally appreciate your point, however I have no control over the CMS.I...
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek