https://wisdmlabs.com/blog/create-adaptive-placeholders-using-css/ https://circleci.com/blog/adaptive-placeholders/ https://stackoverflow.com/question ...
https://wisdmlabs.com/blog/create-adaptive-placeholders-using-css/
https://circleci.com/blog/adaptive-placeholders/
https://stackoverflow.com/questions/47983822/css-operator-adaptive-placeholder-contact-form-7-wordpress
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Adaptive Placeholder – 自適應的占位符效果</title> <style type="text/css"> body { background-color: #FAFAFA; } .top-banner { background: #555; } input[type=text] { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; height: -webkit-calc(3em + 2px); height: calc(3em + 2px); margin: 0 0 1em; padding: 1em; border: 1px solid #cccccc; border-radius: 1.5em; background: #fff; resize: none; outline: none; } input[type=text][required]:focus { border-color: #00bafa; } input[type=text][required]:focus + label[placeholder]:before { color: #00bafa; } input[type=text][required]:focus + label[placeholder]:before, input[type=text][required]:valid + label[placeholder]:before { -webkit-transition-duration: .2s; transition-duration: .2s; -webkit-transform: translate(0, -1.5em) scale(0.9, 0.9); -ms-transform: translate(0, -1.5em) scale(0.9, 0.9); transform: translate(0, -1.5em) scale(0.9, 0.9); } input[type=text][required]:invalid + label[placeholder][alt]:before { content: attr(alt); } input[type=text][required] + label[placeholder] { display: block; pointer-events: none; line-height: 2.3em; margin-top: -webkit-calc(-3em - 2px); margin-top: calc(-3em - 2px); margin-bottom: -webkit-calc((3em - 1em) + 2px); margin-bottom: calc((3em - 1em) + 2px); } input[type=text][required] + label[placeholder]:before { content: attr(placeholder); display: inline-block; margin: 0 -webkit-calc(1em + 2px); margin: 0 calc(1em + 2px); padding: 0 2px; color: #898989; white-space: nowrap; -webkit-transition: 0.3s ease-in-out; transition: 0.3s ease-in-out; background-image: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#ffffff)); background-image: -webkit-linear-gradient(top, #ffffff, #ffffff); background-image: linear-gradient(to bottom, #ffffff, #ffffff); -webkit-background-size: 100% 5px; background-size: 100% 5px; background-repeat: no-repeat; background-position: center; } *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0} .clearfix{*zoom:1} .fl{float:left} .fr{float:right} .fl,.fr{_display:inline} .top-banner { position:absolute; z-index: 999; left:0; top:0; height:40px; line-height:40px; padding:0 30px; width:100%; font-size: 13px; background-color: rgba(255, 255, 255, 0.15); color: #fff; font-family: "宋體","Microsoft Yahei","Helvetica Neue",Helvetica,Arial,sans-serif; font-size: 15px; /*text-shadow: 1px 1px 3px #333;*/ /*box-shadow: 0 1px 0 #999;*/ } .top-banner a { color: #fff; text-decoration: none; } </style> <script type="text/javascript"> $(function() { $("input[id$=address]").qtip({ content: '塗聚文告訴你,好樣的' }); }); </script> </head> <body> <div style="width:400px;height:100px;margin:300px auto"> <form> <input required='必須填寫' type='text' class="name" id="name"> <label alt='請輸入姓名' placeholder='姓名'></label> <input required='必須填寫' type='text' class="address" id="address"> <label alt='請輸入地址' placeholder='地址'></label> </form> </div> <div class="footer-banner" style="width:728px; margin:200px auto 0"></div> <script src="js/jquery.min.js"></script> </body> </html>