css中怎么定义textarea高度最大值maxheight

html-css014

css中怎么定义textarea高度最大值maxheight,第1张

如果您不考虑兼容IE6的话 就

<style>

.a{max-height:200px}/*不兼容IE6*/

/*.a{heihgt:200pxoverflow:hidden} 建议设定一个固定高度,多余的隐藏*/

</style>

<textarea class="a"><textarea>

1.新建网页文件。

2.在head里插入<style type="text/css">#area { width:300pxheight:20px}</style>,表示设置输入文本框宽度为300像素,高度为20像素。

3.在body里插入<input type="text" id="area" />,表示定义一个输入文本框,启用area样式。

4.在IE里测试,查看效果。

OK,搞定,用了一段JS;看能否达到你要求。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>

<style type="text/css">

*{margin:0padding:0border:0}

body{background-color: #666margin: 0pxtext-align:center}

.clear{clear:bothheight:0overflow:hiddenbackground:#0F0height:20px}

.toop{clear:bothheight:0overflow:hiddenbackground:#0F0height:20px}

.webrim{float:leftwidth:10pxbackground:#FF0000overflow:hiddenmargin:0padding:0}

.divstyle{width:940pxbackground:#aaaa00height:1200pxmargin:0px 8px 0px 8px}

</style>

<script type="text/javascript">

window.onload=function(){

document.getElementById('webrim').style.height=document.getElementById('divstyle').clientHeight

document.getElementById('webrim1').style.height=document.getElementById('divstyle').clientHeight

}

</script>

</head>

<body>

<div style="width:980pxheight:100%margin: autobackground-color:#000">

<div class="toop"></div>

<div class="webrim" id="webrim"></div>

<div style="float:leftwidth:960pxbackground:#000">

<div class="divstyle" id="divstyle">中间内容<br /></div>

</div>

<div class="webrim" id="webrim1"></div>

<div class="clear"></div>

</div>

</body>

</html>