Shawn
Shawn

Reputation: 509

How to make a multiple line text box fill parent div

I'm working on a MVC 3 project and CSS has never been my strong point but I have a page laded out with five div's positioned: container, top left, top right, bottom left, and bottom right.

Within the bottom right div it's child is a multiple line text box that I need to fill the parent div adding padding on the right and bottom. #div-notes is assigned to the id property for the text box I need to stretch, and the parent div is #div-container-optional2.

Can someone help me understand why I can't fill this div with a text box?

 #div-container {
     width: fill-available;
     margin: 0 auto;

 }
 #div-content1
 {
     width: 50%;
     float: left;
 }
 #div-content2
 {
     width: 50%;
     float: left;
 }
 #div-container-optional1
 {
     clear: both;
     width: 50%;
     float: left;
 }
 #div-container-optional2
 {
     width: 50%;
     float: left;
     margin-top: 38px;
 }
 #div-submit-button
 {
     clear: both;
     float: left;
     margin-top: 5px;  
 }
 #div-notes {
     width: 200px;
     height: 200px;
     position: relative;
 }

Code form the view:

<div id="div-container-optional2">
  <hr />
  <div class="editor-label">
     @Html.LabelFor(model => model.Notes)
  </div>
  <div id="div-notes" class="editor-field">
     @Html.EditorFor(model => model.Notes)
     @Html.ValidationMessageFor(model => model.Notes)
  </div>
</div>
<div id="div-submit-button">
  <input type="submit" value="Create" />
</div>

Upvotes: 0

Views: 4427

Answers (1)

sachleen
sachleen

Reputation: 31121

Not sure of what you're asking, but to make the textarea fill up the parent container, you can set its width and height to 100%.

<div id="parent">
    <textarea rows="2" cols="20">blah</textarea>    
</div>​​​​​​​​​​​​​​​

#parent {
    border: 1px solid #000;
    width: 200px;
    height: 100px;
    padding: 5px;
}

#parent textarea {
    width: 100%;
    height: 100%;
}

DEMO

Upvotes: 1

Related Questions