SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict capescafe's Avatar
    Join Date
    Dec 2004
    Location
    Bellevue, WA
    Posts
    222
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Restricting width of input text boxes

    I've searched the internet and these forums for my answer but can't seem to find one. Does anyone know...is it possible to restrict the size of your input type="text" boxes? I've used size="2" and maxlength="2" and it still won't get any smaller. I have 3 input type="text boxes side by side. The first one is for 2 digits and the next 2 are for 3 digits. But they all 3 look the same size. I've also tried using width:20px; and different pixel lengths to get it size down. But it just won't get any smaller. I want to make it clear to the users filling out my form that there are 2 digits in the first box and then 3 digits in the next 2. Is this possible to make those boxes smaller? I've also set the font-size to 11px.
    Carolyn (cape's cafe)
    Twitter | My Treehouse Profile | eBookFling

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    style="width: [ENTER SIZE IN PIXELS]" ???

    ^^ Tried this ^^ ??

    e.g.
    Code:
    <input style="width: 100px" type="text" name="textfield" id="textfield" />
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Addict capescafe's Avatar
    Join Date
    Dec 2004
    Location
    Bellevue, WA
    Posts
    222
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    hmmm i had tried this before but in my external stylesheet. for some reason it didn't work. but when i tried it again as an inline style, it now works. i must be missing something. anyways, thanks...i guess i'll just use an inline style for it for now.

    thanks. hope it works in other browsers also. i've only viewed it in IE so far.
    Carolyn (cape's cafe)
    Twitter | My Treehouse Profile | eBookFling

  4. #4
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,095
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    That will work anywhere it doesn't have to be inline, oh and I hope you're not using id="textfield" for each input

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JimmyPaddy View Post
    style="width: [ENTER SIZE IN PIXELS]" ???
    Why in the world would you use pixels for this? An input field will contain text, so the width should be set in em.
    Birnam wood is come to Dunsinane

  6. #6
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,095
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    I've used pixels for the width of inputs before, I see you're point but I wouldn't want my layout breaking if the user changed their font-size

    My choice would be dependant on the design - and not simply because it contains text.

  7. #7
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because sometimes the design may require it. Thankfully those instances are few and far between, however.


Bookmarks

Posting Permissions

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