<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function checkLength(which) {
var maxchar=100;
var oTextCount = document.getElementById("char");
iCount = which.value.replace(/[^\u0000-\u00ff]/g,"aa").length;
if(iCount<=maxchar)
{
oTextCount.innerHTML = "<font color=#FF0000>"+ iCount+"</font>";
which.style.border = '1px dotted #FF0000';
which.size=iCount+2;
}
else alert("请不要超过"+maxchar);
}
</script>
</head>
<body>
<input name="words" size="2" maxlength="100" οnkeyup="checkLength(this)"/>
<span id="char">0</span>个字符
</body>
</html>
<center>
input高度固定,自动增宽<br>
<input type="text" style="width:60;overflow-x:visible;overflow-y:visible;">
<br>
<br>
textarea宽度固定,自动增高<br>
<textarea type="text" style="width:260;overflow-x:visible;overflow-y:visible;"></textarea>
input宽度自适应
原创zhangying2001 ©著作权
©著作权归作者所有:来自51CTO博客作者zhangying2001的原创作品,请联系作者获取转载授权,否则将追究法律责任

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
vue 实现input框的宽度自适应?
要实现Vue中input框的宽度自适应,可以使用CSS的`width`属性和Vue的数据绑定来实现。下面是一个简单的示例:1. 在Vue组件的模板
vue.js 前端 javascript ecmascript 前端框架 -
echarts 自适应宽度
一个页面只有一个echarts图形时,可以写为myChart.setOption(option);window.onresize = myChart.resize; 一个页面
echarts 自适应宽度 myChart options resize -
[css] 宽度自适应
元素的宽度是由子元素或者文本撑开<!DOCTYPE html><html lang="en"><h
css html 自适应 固定宽度 -
【自适应宽度】一
如果丘处机没有路过牛家村,中国将是最发达国家
html ide 知识