【问题标题】:Textarea 100% height in IEIE中的Textarea 100%高度
【发布时间】:2010-06-14 09:21:48
【问题描述】:

如何让我的<textarea> 具有 100% 的高度并在 IE7/6 中工作? height:100% 在所有其他浏览器中都可以正常工作,但 IE 只是不想接受除特定值之外的任何内容。 Javascript 是一种可能的解决方案。

【问题讨论】:

    标签: css textarea height


    【解决方案1】:

    为了让一个元素在 IE6 中达到 100% 的高度,您需要指定其父元素的固定高度。如果要使元素成为页面的全长,请应用 height:100%;到 html 和 body 元素。

    /*100% height of the parent element for IE6*/ 
    #parent {height:500px;}
    #child {height:100%;}
    
    /*100% of the page length for IE6*/ 
    html, body {height:100%;}
    #fullLength {height:100%;}
    

    取自:http://www.virtuosimedia.com/

    我猜这同样适用于 IE7。

    【讨论】:

    • 这适用于 div,但不适用于 textarea。我试过了。
    • 您不能将与<textarea> 相关联的<label> 包裹起来并对其应用父样式吗?
    【解决方案2】:

    我想在这里留下一个答案,因为我有同样的问题,上面的答案并不完全有帮助。

    适用于除 IE6-7 以外的所有浏览器

      div#parent {height:500px;}
      textarea#child {height:100%;}
    

    但是对于IE6-7你需要设置:

      textarea#child {
          height:100%;
          position: absolute;
      }
    

    【讨论】:

    • 哦。感谢一个小错误。必须是 div#parent 和 textarea#child
    • @Teneff, textarea#child 表示 id 为 child 的文本区域。如果要选择 id 为childinside textarea 的元素,则应使用textarea #child。注意textarea#child 之间有一个空格。
    猜你喜欢
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-14
    • 1970-01-01
    • 2015-03-10
    • 1970-01-01
    相关资源
    最近更新 更多