纯css实现登录表单动效

效果图:

代码展示

javascript 复制代码
// 我这边用的是elementUI表单校验,更改的样式。
<el-form
      :model="form"
      :rules="rules"
       ref="fromList"
      :hide-required-asterisk="true">
    <el-form-item prop="account">
		<div class="input-data">
   			<el-input required="" v-model="form.account" autocomplete="on"></el-input>
   			<label>手机号/邮箱</label>
		</div>
	</el-form-item>
	   <el-form-item prop="pass">
		<div class="input-data">
   			<el-input required="" v-model="form.pass" autocomplete="on"></el-input>
   			<label>密码</label>
		</div>
	</el-form-item>
<el-form>

.input-data{
  width: 100%;
  height: 40px;
  position: relative;
}
 :deep(.el-form){
   .el-form-item{
     margin-bottom: 62px;
   }
   .el-form-item__error{
     font-size: 14px;
     color: #F15151;
     line-height: 1.7;
     letter-spacing: 1px;
   }
   .el-input__inner{
     padding: 0;
     color: #FFFFFF;
     width: 100%;
     height: 40px;
     border: none;
     border-radius:0;
     border-bottom: 1px solid silver;
     font-size: 16px;
     background: transparent;
   }
   .is-required.is-error .el-input__inner{
     border:none !important;
     border-bottom:1px solid #FFFFFF !important;
   }
   
   .input-data{
  		 label{
  			font-size: 16px;
 			font-weight: normal;
 			color: #FFFFFF;
  			letter-spacing: 1px;
  			position: absolute;
  			bottom: 0;
  			left: 0;
 			pointer-events: none;
 			transition: all 0.3s ease;
		}
     .el-input:has(> input:focus) ~ label,
     .el-input:has(> input:valid) ~ label,
     //处理记住密码填充的bug
     .el-input:has(>input:-webkit-autofill) ~ label{
       transform: translateY(-30px);
       font-size: 13px ;
     }
   }
 }
 
相关推荐
cyadyx1 小时前
Vite 比 Webpack 构建效率更高
前端·webpack·node.js·vite
mCell3 小时前
AI 时代 SVG 画图的潜力
前端·agent·svg
我命由我123458 小时前
CesiumJS 笔记 - 获取容器中心点、Cartesian3 clone 方法、修改 Cartesian3 对象的高度
前端·javascript·css·前端框架·html·html5·js
Hopebearer_9 小时前
页面突然只剩 DOM?一次静态资源版本错配排查
前端·部署
东风破_10 小时前
ESLint 是什么?为什么你的项目需要它?
前端·后端·代码规范
圣殿骑士-Khtangc11 小时前
Go字符串高效拼接性能对比与底层原理分析
服务器·前端·golang
BigTopOne12 小时前
【ijkplayer】 硬解码流程
前端
kyriewen12 小时前
DeepSeek Harness开源第一天我就上手了——和Claude Code的差距比想象中大
前端·ai编程·deepseek
捡田螺的小男孩13 小时前
什么是 Skill?手把手带你写一个简单有用的 Skill!
前端·后端·程序员
IT_陈寒13 小时前
Redis集群这个坑,差点让我通宵
前端·人工智能·后端