簡體   English   中英

為IE 11自動調整textarea

[英]Autoresize textarea for IE 11

自動調整大小為10行的textarea然后滾動條工作。 它的工作,但滾動條blinkig和文本跳躍。 所以我需要它用於角度項目,然后將此代碼編譯為Web組件。 這里有一些代碼:jsbin.com/qivakevaxa/1/edit?html,css,js,output

您的代碼適用於我這邊的Chrome和IE 11瀏覽器。

如果您的意思是想在角度應用程序中使用代碼,可以參考以下代碼:

about.component.ts中的代碼:

import { Component, OnInit } from '@angular/core';
@Component({
  selector: 'app-about',
  templateUrl: './about.component.html',
  styleUrls: ['./about.component.css']
})
export class AboutComponent implements OnInit {
  ngOnInit() {
  }
  onchange(event) {
    event.target.style.height = 'auto';
    event.target.style.height = event.target.scrollHeight+'px';
    event.target.scrollTop = event.target.scrollHeight;
    console.log( "Input Event:", event.target.value );
  }
}

about.component.html中的代碼:

<textarea id="mytextarea" (input)="onchange($event)" rows='3'>Type here and I’ll resize.</textarea>

about.component.css中的代碼:

    textarea {
      display: block;
      /* resize: none; */
      box-sizing:border-box;
      max-height:200px;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM