zoukankan      html  css  js  c++  java
  • input相关问题总结

    1. 禁止为所有被激活的输入框添加边框

    *:focus {outline: none} 

    2. 禁止为被激活的输入框添加边框,说明:".abc"为输入框对象自定义添加的class类命名。

    .abc:focus{ outline:none } 

    3. 也可以自定义输入框被激活时的边框样式

    .abc:focus { outline:Blue Solid 4px;} 

    4.为所有input为text password 的设置激活时的边框样式

    input[type="text"]:focus, input[type="password"]:focus { border: 1px #1E90FF solid; background-color: #fff;box-shadow: 0 0 4px rgba(30,144,255,.5);}

    5.把input写在label里面 无论是点击文字 还是复选框 都可以勾选复选框

    <P><label><input type="checkbox" />点我 <label><input type="checkbox" />点我 <label><input type="checkbox" />点我 </P>

    6.给多个input加focus样式

    <!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>
    <style type="text/css">
    body{
        font:normal 12px/17px Arial;
    }
    div{
        padding:2px;
    } 
    input, textarea { 
         width: 12em; 
         border: 1px solid #888;
    }
    .focus { 
         border: 1px solid #f00;
         background: #fcc;
    } 
    </style>
    <!--   引入jQuery -->
    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function(){
            $(":input").focus(function(){
                  $(this).addClass("focus");
                  if($(this).val() ==this.defaultValue){  
                      $(this).val("");           
                  } 
            }).blur(function(){
                 $(this).removeClass("focus");
                 if ($(this).val() == '') {
                    $(this).val(this.defaultValue);
                 }
            });
        })
        </script>
    
    
    </head>
    <body>
        <form action="" method="post" id="regForm">
            <fieldset>
                <legend>个人基本信息</legend>
                    <div>
                        <label  for="username">名称:</label>
                        <input id="username" type="text" value="名称" />
                    </div>
                    <div>
                        <label for="pass">密码:</label>
                        <input id="pass" type="password" value="密码" />
                    </div>
                    <div>
                        <label for="msg">详细信息:</label>
                        <textarea id="msg" rows="2" cols="20">详细信息</textarea>
                    </div>
            </fieldset>
        </form>
    </body>
    </html>

     7.

    <input type="text" value="搜索"  placeholder="搜索" onfocus="this.value=''" />

    默认颜色鼠标点击字体颜色变浅  输入后文字自动消失

  • 相关阅读:
    gitlab搭建
    java数组
    安裝nextcloud
    Spring的定时任务@Scheduled(cron = "0 0 1 * * *")
    java内存结构(下)
    java内存结构(上)
    多线程的三个特性
    @RequestBody用法
    SwaggerAPI注解详解(转载)
    在jpanel中添加jbutton并自由设置按钮大小和位置
  • 原文地址:https://www.cnblogs.com/Xuman0927/p/5265343.html
Copyright © 2011-2022 走看看