CSS/HTML: Create a glowing border around an Input Field

后端 未结 11 2399
野的像风
野的像风 2020-12-02 03:39

I want to create some decent inputs for my form, and I would really like to know how TWITTER does their glowing border around their inputs.

Example/Picture of the Tw

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 04:25

    $('.form-fild input,.form-fild textarea').focus(function() {
        $(this).parent().addClass('open');
    });
    
    $('.form-fild input,.form-fild textarea').blur(function() {
        $(this).parent().removeClass('open');
    });
    .open {
      color:red;   
    }
    .form-fild {
    	position: relative;
    	margin: 30px 0;
    }
    .form-fild label {
    	position: absolute;
    	top: 5px;
    	left: 10px;
    	padding:5px;
    }
    
    .form-fild.open label {
    	top: -25px;
    	left: 10px;
    	/*background: #ffffff;*/
    }
    .form-fild input[type="text"] {
    	padding-left: 80px;
    }
    .form-fild textarea {
    	padding-left: 80px;
    }
    .form-fild.open textarea, 
    .form-fild.open input[type="text"] {
    	padding-left: 10px;
    }
    textarea,
    input[type="text"] {
    	padding: 10px;
    	width: 100%;
    }
    textarea,
    input,
    .form-fild.open label,
    .form-fild label {
    	-webkit-transition: all 0.2s ease-in-out;
           -moz-transition: all 0.2s ease-in-out;
             -o-transition: all 0.2s ease-in-out;
                transition: all 0.2s ease-in-out;
    }
    
    

提交回复
热议问题