---
title: "input输入框的各种样式 文本框为下划线 text输入框样式"
author: "h271665724"
date: "2011-12-21T17:51:20Z"
tags: []
categories: ["Web前端"]
slug: "input-text"
draft: false
lastmod: "2011-12-21T17:51:20Z"
id: 1319875
url: "https://java161.iteye.com/blog/1319875"
---

input输入框的各种样式 文本框为下划线 text输入框样式

 

输入框景背景透明：  
&lt;input style="background:transparent;border:1px solid #ffffff"&gt;

鼠标划过输入框，输入框背景色变色：  
&lt;INPUT value="Type here" NAME="user\_pass" TYPE="text" SIZE="29" onmouseover="this.style.borderColor='black';this.style.backgroundColor='plum'"  
style="width: 106; height: 21"  
onmouseout="this.style.borderColor='black';this.style.backgroundColor='#ffffff'" style="border-width:1px;border-color=black"&gt;

 

输入字时输入框边框闪烁(边框为小方型)：  
&lt;Script Language="JavaScript"&gt;  
function borderColor(){  
if(self\['oText'].style.borderColor=='red'){  
self\['oText'].style.borderColor = 'yellow';  
}else{  
self\['oText'].style.borderColor = 'red';  
}  
oTime = setTimeout('borderColor()',400);  
}  
&lt;/Script&gt;  
&lt;input type="text" id="oText" style="border:5px dotted red;color:red" onfocus="borderColor(this);" onblur="clearTimeout(oTime);"&gt;

 

输入字时输入框边框闪烁(边框为虚线)：  
&lt;style&gt;  
#oText{border:1px dotted #ff0000;ryo:expression\_r(onfocus=function light (){with(document.all.oText){style.borderColor=(style.borderColor=="#ffee00"?"#ff0000":"#ffee00");timer=setTimeout(light,500);}},onblur=function(){this.style.borderColor="#ff0000";clearTimeout(timer)})};  
&lt;/style&gt;  
&lt;input type="text" id="oText"&gt;

 

自动横向廷伸的输入框：

&lt;input type="text" style="huerreson:expression\_r(this.width=this.scrollWidth)" value="abcdefghijk"&gt;

 

自动向下廷伸的文本框：  
&lt;textarea name="content" rows="6" cols="80" onpropertychange="if(this.scrollHeight&gt;80) this.style.posHeight=this.scrollHeight+5"&gt;输入几个回车试试&lt;/textarea&gt;

只有下划线的文本框：

&lt;input style="border:0;border-bottom:1 solid black;background:;"&gt;

软件序列号式的输入框：  
&lt;script for="T" event="onkeyup"&gt;  
if(value.length==3)document.all\[event.srcElement.sourceIndex+1].select();  
&lt;/script&gt;  
&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T7" size="5" maxlength="3"&gt;

 

软件序列号式的输入框(完整版)：  
&lt;script for="T" event="onkeyup"&gt;if(value.length==maxLength)document.all\[event.srcElement.sourceIndex+1].focus();&lt;/script&gt;  
&lt;script for="T" event="onfocus"&gt;select();&lt;/script&gt;  
&lt;script for="Submit" event="onclick"&gt;  
var sn=new Array();  
for(i=0;i&lt;T.length;i++)  
sn=T.value;  
alert(sn.join("—"));  
&lt;/script&gt;  
&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T" size="5" maxlength="3"&gt;—&lt;input name="T" size="5" maxlength="3"&gt;  
&lt;input type="submit" name="Submit"&gt;