1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Vertically aligning text in a textarea

Discussion in 'HTML, Graphics & Programming' started by Bes, 25 Sep 2009.

  1. Bes

    Soldato

    Joined: 18 Oct 2002

    Posts: 7,277

    Location: The Ghetto: AKA Brixton

    Hi,

    The above is driving me crazy- I cannot find a decent way (CSS/ Javascript/ jquery whatever) to get text to be vertically aligned to the centre of a text area- so even if the user types more text in, it stays vertically aligned to the centre.

    Can anyone help?

    Thanks
     
  2. daz

    Capodecina

    Joined: 18 Oct 2002

    Posts: 23,994

    Location: Bucks

    Correct me if i'm wrong, but this is one area where CSS falls down (or at least CSS with cross browser compatibility)... you may have to use a table with the text inside for this (valign = middle) IIRC. :o
     
  3. Bes

    Soldato

    Joined: 18 Oct 2002

    Posts: 7,277

    Location: The Ghetto: AKA Brixton

    A table inside the text box? Is that even possible?
     
    Last edited: 25 Sep 2009
  4. daz

    Capodecina

    Joined: 18 Oct 2002

    Posts: 23,994

    Location: Bucks

    Oh... inside the text area? Thought you meant alongside or something :o Ignore me then
     
  5. simisker

    Mobster

    Joined: 27 Oct 2002

    Posts: 3,533

    Location: At the fulcrum of humdrum

    Use the table cell to create a false textarea. Place the true textarea within that table cell [valign'ed, of course], with borders removed and with some padding in the cell to avoid the true textarea from going right to the edges.
     
  6. suarve

    Mobster

    Joined: 8 Oct 2005

    Posts: 4,190

    Location: Midlands, UK

    That's a good idea, but some browsers add a scroll bar to the right
     
  7. simisker

    Mobster

    Joined: 27 Oct 2002

    Posts: 3,533

    Location: At the fulcrum of humdrum

    Argh, you're right. Oh well, strike two :D
     
  8. suarve

    Mobster

    Joined: 8 Oct 2005

    Posts: 4,190

    Location: Midlands, UK

    Was a nice idea though :)

    EDIT: actually, there's probably some obsure browser specific setting you could use to disable this.
     
  9. Bes

    Soldato

    Joined: 18 Oct 2002

    Posts: 7,277

    Location: The Ghetto: AKA Brixton

    hey would this method definately work? What do you mean by a false text area?

    /noob

    Thanks
     
  10. suarve

    Mobster

    Joined: 8 Oct 2005

    Posts: 4,190

    Location: Midlands, UK

    It might work in certain browsers, but some browsers add a disabled vertical scroll bar to text areas. Say you're making some sort of internal system where you know exactly what browser software people are using, you may get away with it.
     
  11. Bes

    Soldato

    Joined: 18 Oct 2002

    Posts: 7,277

    Location: The Ghetto: AKA Brixton

    Afraid not, people could be using anything :(
     
  12. Imy

    Mobster

    Joined: 21 Nov 2005

    Posts: 2,771

    Location: Nuneaton, UK

    Have a look at the css overflow setting with regards to the above suggestions.