Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    23
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Make drop-downs in form the same width

    Hi,

    There is probably a really simple answer to this, but...I don't know it!

    I have a form with one text input box and three drop-downs:



    How can I make them all the same width so it looks neat?

    Thanks, jake66
    Last edited by jake66; 08-02-2011 at 12:02 PM. Reason: spelling made meaning unclear

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Just use some CSS width styling, something like this:
    Code:
    select {width:250px;}
    If you want the input element to be the same width as the select elements then you can just add the input to the style also, like this:
    Code:
    select,input {width:250px;}
    Just adjust the 250px figure there to whatever width looks good to you.

    Note that this will make the submit button also that same width, so you will need to give the submit button an ID or a class and then adjust the width for that specific class separately. That could look something like this:
    Code:
    HTML:
    <input type="submit" class="submit_button" value="Submit" />
    
    CSS:
    input.submit_button {width:auto;}
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • Users who have thanked Rowsdower! for this post:

    jake66 (08-03-2011)

  • #3
    New Coder
    Join Date
    Jul 2011
    Posts
    23
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Rowsdower! View Post
    Just use some CSS width styling, something like this:
    Code:
    select {width:250px;}
    If you want the input element to be the same width as the select elements then you can just add the input to the style also, like this:
    Code:
    select,input {width:250px;}
    Just adjust the 250px figure there to whatever width looks good to you.

    Note that this will make the submit button also that same width, so you will need to give the submit button an ID or a class and then adjust the width for that specific class separately. That could look something like this:
    Code:
    HTML:
    <input type="submit" class="submit_button" value="Submit" />
    
    CSS:
    input.submit_button {width:auto;}
    Thanks!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •