SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Textarea stretching

    Is it possible to set a textarea to stretch (or shrink) to fill a div (the width of the div is set using %)? I can't work out how to do this in CSS.

  2. #2
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    Code:
    <textarea style="width:100%"></textarea>
    hth,
    Douglas
    Hello World

  3. #3
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Doug, but tried that with no joy.

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Try this javascript:
    Code:
    (assume your textarea is named "textarea1" and your div is named "mydiv")
    <script language="javascript" type="text/javascript">
    document.getElementById('textarea1').style.width = document.getElementById('mydiv').style.width;
    </script>
    code is untested.

    --Vinnie

  5. #5
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by mserms
    Cheers Doug, but tried that with no joy.
    Can you link to where you are having the problem?

    The style I gave you should size the text area to fill its parent. It may be because of a form element constraining it or something?

    Rephrase for putting it in a style sheet:

    Code:
    textarea {
     width: 100%;
    }
    Douglas
    Hello World

  6. #6
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wait up Doug it's just started working and I've not done anything. I'll try to suss this out...



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
  •