skip to Main Content

Why is my textarea shrinking automatically when i open the page.
It looks like this

And when i refresh the page it goes to normal again. What may be the issue
normal

And this is my html code

<div class="col-md-12 input-group pab pcomment">
        <div class="input-group-prepend">
          <span class="input-group-text">Comment</span>
        </div>
        <textarea matinput formControlName="pastMedicalHistoryComment" class="form-control" aria-label="Comment"></textarea>
    </div>

And this my formcontroll css

.input-group>.custom-file, .input-group>.custom-select, .input-group>.form-control {
    position: relative;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    width: 1%;
    margin-bottom: 0;
}

2

Answers


  1. just give it some min-width:400px or some pixels that you want to give default minimum width.

    .input-group>.custom-file, .input-group>.custom-select, .input-group>.form-control {
        position: relative;
        -ms-flex: 1 1 auto;
        flex: 1 1 auto;
        width: 1%;
        margin-bottom: 0;
        min-width:400px;
    }
    <div class="col-md-12 input-group pab pcomment">
            <div class="input-group-prepend">
              <span class="input-group-text">Comment</span>
            </div>
            <textarea matinput formControlName="pastMedicalHistoryComment" class="form-control" aria-label="Comment"></textarea>
        </div>
    Login or Signup to reply.
  2. You essentially want this, but I’ll let you incorporate it with BS:

    div {
      display: flex; 
      align-items: center;
    }
    label {
      padding: 10px;
      width: max-content;
      background: #f7f7f7;
    }
    textarea {
      flex: 1 1 auto;
    }
    <div>
      <label>Comment</label>
      <textarea></textarea>
    </div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search