input输入框获得焦点、失去焦点效果

废话shao shuo ! 直接效果图,好吧!

效果图

请添加图片描述

code:

<!DOCTYPE html>
<html>
<head>
	&lt;title&gt;</title&gt;
	<meta charset="utf-8" />
	<style type="text/css">
		*{margin:0;padding:0;}
		#box{width:200px;height:30px;border-bottom:1px solid #a8a8a8;margin:30px auto;position:relative;}
		#box .input{width:100%;height:100%;outline:none;border:none;font-size:16px;}
		#box .line{width:0px;height:2px;background:#00aeff;position:absolute;bottom:-1px;left:50%;transform:translateX(-50%);transition:width 0.4s ease;}
		#box .placeh{position:absolute;left:4px;top:5px;transition:top 0.4s ease;color:#cbcbcb;}
		
		#box .placeh:hover{cursor:text;}
		#box .input:focus ~ .line{width:100%;}
		#box .input:focus ~ .placeh,
		#box .input:valid ~ .placeh{top:-26px;color:#00a2ff;}

	</style>
</head>
<body>

<div id="box">
	<input type="text" id="input" class="input" required >
	<span class="line"></span>
	<label class="placeh" for="input">Enter your account</label>
</div>

</body>
<script>
</script>
</html>


—- 结束 —-
学习

原文地址:https://blog.csdn.net/qq_52722885/article/details/129228857

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_44906.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注