*新闻详情页*/>
更多精彩內容请关心 https://github.com/abc-club/free-resources
情况
话很少说,大家能否用纯css完成下列实际效果:
回答是毫无疑问的。
依靠css:placeholder-shown :valid :invalid伪类及html5 input pattern 特性便可以完成
:placeholder-shown伪类现阶段适配性以下:
:placeholder-shown适配性
立即上编码!☺️
源代码
https://jsbin.com/qenucaz/edit?html,css,output
html:
<!DOCTYPE html> <html> <head> <meta charset="utf⑻"> <meta name="viewport" content="width=device-width"> <title>JS Bin</title> </head> <body> <div class="input-fill-box"> <input class="input-fill" placeholder="电子邮箱" pattern="^[A-Za-z0⑼\u4e00-\u9fa5]+@[a-zA-Z0⑼_-]+(\.[a-zA-Z0⑼_-]+)+$" required> <a href="javascript:" class="clear">close</a> <label class="input-label">电子邮箱</label> </div> </body> </html>
css:
.input-fill{ width: 100%; margin: 0; font-size: 16px; line-height: 1.5; outline: none; padding: 20px 16px 6px; border: 1px solid transparent; background: #f5f5fa; border-radius:10px; transition: border-color .25s; } .input-fill:placeholder-shown::placeholder { color: transparent; } .input-fill-box { width: 50%; position: relative; } .input-label { position: absolute; left: 16px; top: 14px; pointer-events: none; color:#BEC1D9; padding: 0 2px; transform-origin: 0 0; pointer-events: none; transition: all .25s; } .input-fill:not(:placeholder-shown) ~ .input-label, .input-fill:focus ~ .input-label { transform: scale(0.75) translate(0px, ⑴4px); } .input-fill:focus{ border: 2px solid #1d31aa; } .clear{ position:absolute; top:10px; right:⑵0px; display: none; transition: all .25s; } .input-fill::-ms-clear { display: none; } .input-fill:not(:placeholder-shown) + .clear { display: inline; } .input-fill:valid { border-color: green; box-shadow: inset 5px 0 0 green; } .input-fill:not(:placeholder-shown):invalid { border-color: red; box-shadow: inset 5px 0 0 red; }
更多
更多精彩內容请关心 https://github.com/abc-club/free-resources
以上便是本文的所有內容,期待对大伙儿的学习培训有一定的协助,也期待大伙儿多多适用脚本制作之家。
Copyright © 2002-2020 小游戏源代码_互动小游戏微信_自制小游戏_html5游戏_制作游戏大概多少钱 版权所有 (网站地图) 粤ICP备10235580号