zoukankan      html  css  js  c++  java
  • html---文本框样式;

    一、一个单行文本框的例子

    <form name="form1" action="mailto:3400982550@qq.com" method="post" enctype="text/plain">
    <p>您的姓名: <input type="text" name="text1" size="12" maxlength="20">
    您的E_mail: <input type="text" name="text2" size="20" maxlength="24" value="*****@*.*">
    输入口令: <input type="password" name="text3" size="8" maxlength="8"> </p>
    <p align="center"> 
    <input type="submit" name="提交" value="提 交">
    <input type="reset" name="重写" value="重 写">
    </p>
    </form>

    二、检验用户输入的信息

    <script language="javascript">
    <!--
    function test(form){
    test1(form);
    test2(form);
    test3(form)}
    function test1(form){
    if (form.text1.value=="")
    alert("你没有写上你的姓名,请输入姓名!")
    }
    function test2(form){
    if (form.text2.value==""||form.text2.value.indexOf('@',0)==-1)
    alert("E_mail地址不正确,请重新输入!")
    }
    function test3(form){
    if (form.text3.value!="12345678")
    alert("密码错误,请重新输入!")
    }
    -->
    </script>

    三、制作一个留言簿

    <form name="form2" action="mailto:fyy0528@sina.com" method="post" enctype="text/plain" >
    <table width="50%" border="1" bordercolorlight="#000000" bordercolordark="#FFFFFF" bgcolor="#CCFFCC" cellpadding="4" align="left">
    <tr> 
    <td colspan="2"> <div align="center"><b>留 言 簿</b></div> </td>
    </tr>
    <tr> 
    <td>姓名: <input type="text" name="textfield" size="8"> </td>
    <td>E_mail: <input type="text" name="textfield2" size="10" maxlength="20"> </td>
    </tr>
    <tr> 
    <td colspan="2"> <div align="center">留 言<br> <textarea name="textfield3" cols="30" rows="3"></textarea>
    </div>
    </td>
    </tr>
    <tr> 
    <td> <div align="right"> <input type="submit" name="Submit" value="提 交"> </div> </td>
    <td> <input type="reset" name="Submit2" value="重 写"> </td>
    </tr>
    </table>
    </form>

    html文本框参考样式

    输入框景背景透明:

    <input style="background:transparent;border:1px solid #ffffff">

    鼠标划过输入框,输入框背景色变色:

    <INPUT value="Type here" NAME="user_pass" TYPE="text" SIZE="29" onmouseover="this.style.borderColor='black';this.style.backgroundColor='plum'"
    style=" 106; height: 21"
    onmouseout="this.style.borderColor='black';this.style.backgroundColor='#ffffff'" style="border-1px;border-color=black">

    输入字时输入框边框闪烁(边框为小方型):

    <Script Language="JavaScript">
    function borderColor(){
    if(self['oText'].style.borderColor=='red'){
    self['oText'].style.borderColor = 'yellow';
    }else{
    self['oText'].style.borderColor = 'red';
    }
    oTime = setTimeout('borderColor()',400);
    }
    </Script>
    <input type="text" id="oText" style="border:5px dotted red;color:red" onfocus="borderColor(this);" onblur="clearTimeout(oTime);">

    输入字时输入框边框闪烁(边框为虚线):

    <style>
    #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)})};
    </style>
    <input type="text" id="oText">
     

    自动横向廷伸的输入框:

    <input type="text" style="huerreson:expression_r(this.width=this.scrollWidth)" value="abcdefghijk">

    自动向下廷伸的文本框:

    <textarea name="content" rows="6" cols="80" onpropertychange="if(this.scrollHeight>80) this.style.posHeight=this.scrollHeight+5">输入几个回车试试</textarea>

    只有下划线的文本框:

    <input style="border:0;border-bottom:1 solid black;background:;">

    html文本框常见操作技巧

    1、html文本框怎么用css变圆角
     

    border-radius属性可以实现元素的圆角。如下css可以实现文本框(单行、多行)的圆角:
    input[type=text],textarea{border-radius:3px;border:1px solid #000;}

    border-radius用法如下:
    border-radius 属性是一个简写属性,用于设置四个 border-*-radius 属性。
    该属性允许为元素添加圆角边框
    语法:

    border-radius: 1-4 length|% / 1-4 length|%;

    按此顺序设置每个 radius 的四个值。
    如果省略 bottom-left,则与 top-right 相同。
    如果省略 bottom-right,则与 top-left 相同。
    如果省略 top-right,则与 top-left 相同。
    单位一般用px和百分比较多,其他单位也可

    2、HTML中如何设置文本框的大小

    边框的大小,可以使用CSS样式控制,如:
    <textarea id="txtCon" >content</textarea>
    <style type="text/css">
    #txtCon{100px; height:20px;}
    </style>

    也可以使用文本框自己的属性,定义文本框的行和列控制大小,如:
    <textarea id="txtCon" rows="100" cols="100" >content</textarea>

    3、在html中如何实现将本网页中文本框中的值传递到另一个网页的用户名密码框中,并实现登陆

    在html网页中,一个按钮,两个文本框,在<SCRIPT language=JavaScript> /SCRIPT>当中如何写代码能够实现将这两个文本框中的值传递到另一个制定地址的网页中的用户名和密码处,并实现登陆?

    页面必须是跳转过去的才行。例如另一个页面是page.html那么你跳转的时候 page.html?username=tony&password=123 跳转到这个地址,

    然后到另一个页面的时候在脚本里面写
    <SCRIPT language=JavaScript>
    var url = window.location.href;
    然后var username = url.split("?")[1].split("&")[0].split("=")[1] //这样就获取到用户名了。
    var password = url.split("&")[1].split("=")[1];

    然后把值赋给你的密码文本框
    document.getElementById("txtpassword").value = password;
    document.getElementById("txtusername").value=username;
    < /SCRIPT>

    然后验证用户名和密码就可以了。

    4、HTML中让表单input等文本框为只读不可编辑的方法

    有时候,我们希望表单中的文本框是只读的,让用户不能修改其中的信息,如使<input type="text" name="input1" value="中国"> 的内容,"中国"两个字不可以修改。实现的方式归纳一下,有如下几种。 

    方法1: onfocus=this.blur() 当鼠标放不上就离开焦点
    <input type="text" name="input1" value="中国" onfocus=this.blur()> 

    方法2:readonly 
    <input type="text" name="input1" value="中国" readonly> 
    <input type="text" name="input1" value="中国" readonly="true"> 

    方法3: disabled 
    <input type="text" name="input1" value="中国" disabled="true">

    完整的例子:

    <input name="ly_qq" type="text" tabindex="2" onMouseOver="this.className='input_1'" onMouseOut="this.className='input_2'" value="123456789" disabled="true" readOnly="true" /> 

    disabled="true" 此果文字会变成灰色,不可编辑。 
    readOnly="true" 文字不会变色,也是不可编辑的

    css屏蔽输入:<input style="ime-mode: disabled"> 

    有两种方法第一:disabled="disabled"这样定义之后被禁用的 input 元素既不可用,也不可点击。第二:readonly="readonly" 只读字段是不能修改的。不过,用户仍然可以使用 tab 键切换到该字段,还可以选中或拷贝其文本;

  • 相关阅读:
    C#对文件的操作
    Quartz使用
    北邮校园网自动登录 python
    interactive python ---- week5
    interactive python ----pong game
    自旋锁(spinlock)(转)
    interactive python(3)
    interactive python(2)
    Ubuntu下为Firefox安装Adobe Flash Player(转)
    flex中list 控件行中添加Button后的点击事件处理
  • 原文地址:https://www.cnblogs.com/xingyue1988/p/6106067.html
Copyright © 2011-2022 走看看