经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » HTML5 » 查看文章
Adaptive Placeholders
来源:cnblogs  作者:?Geovin Du Dream Park?  时间:2018/12/25 9:27:26  对本文有异议

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

  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  5. <title>Adaptive Placeholder – 自适应的占位符效果</title>
  6. <style type="text/css">
  7. body {
  8. background-color: #FAFAFA;
  9. }
  10. .top-banner {
  11. background: #555;
  12. }
  13. input[type=text] {
  14. -webkit-box-sizing: border-box;
  15. -moz-box-sizing: border-box;
  16. box-sizing: border-box;
  17. width: 100%;
  18. height: -webkit-calc(3em + 2px);
  19. height: calc(3em + 2px);
  20. margin: 0 0 1em;
  21. padding: 1em;
  22. border: 1px solid #cccccc;
  23. border-radius: 1.5em;
  24. background: #fff;
  25. resize: none;
  26. outline: none;
  27. }
  28. input[type=text][required]:focus {
  29. border-color: #00bafa;
  30. }
  31. input[type=text][required]:focus + label[placeholder]:before {
  32. color: #00bafa;
  33. }
  34. input[type=text][required]:focus + label[placeholder]:before, input[type=text][required]:valid + label[placeholder]:before {
  35. -webkit-transition-duration: .2s;
  36. transition-duration: .2s;
  37. -webkit-transform: translate(0, -1.5em) scale(0.9, 0.9);
  38. -ms-transform: translate(0, -1.5em) scale(0.9, 0.9);
  39. transform: translate(0, -1.5em) scale(0.9, 0.9);
  40. }
  41. input[type=text][required]:invalid + label[placeholder][alt]:before {
  42. content: attr(alt);
  43. }
  44. input[type=text][required] + label[placeholder] {
  45. display: block;
  46. pointer-events: none;
  47. line-height: 2.3em;
  48. margin-top: -webkit-calc(-3em - 2px);
  49. margin-top: calc(-3em - 2px);
  50. margin-bottom: -webkit-calc((3em - 1em) + 2px);
  51. margin-bottom: calc((3em - 1em) + 2px);
  52. }
  53. input[type=text][required] + label[placeholder]:before {
  54. content: attr(placeholder);
  55. display: inline-block;
  56. margin: 0 -webkit-calc(1em + 2px);
  57. margin: 0 calc(1em + 2px);
  58. padding: 0 2px;
  59. color: #898989;
  60. white-space: nowrap;
  61. -webkit-transition: 0.3s ease-in-out;
  62. transition: 0.3s ease-in-out;
  63. background-image: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#ffffff));
  64. background-image: -webkit-linear-gradient(top, #ffffff, #ffffff);
  65. background-image: linear-gradient(to bottom, #ffffff, #ffffff);
  66. -webkit-background-size: 100% 5px;
  67. background-size: 100% 5px;
  68. background-repeat: no-repeat;
  69. background-position: center;
  70. }
  71. *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
  72. .clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0}
  73. .clearfix{*zoom:1}
  74. .fl{float:left}
  75. .fr{float:right}
  76. .fl,.fr{_display:inline}
  77. .top-banner {
  78. position:absolute;
  79. z-index: 999;
  80. left:0;
  81. top:0;
  82. height:40px;
  83. line-height:40px;
  84. padding:0 30px;
  85. width:100%;
  86. font-size: 13px;
  87. background-color: rgba(255, 255, 255, 0.15);
  88. color: #fff;
  89. font-family: "宋体","Microsoft Yahei","Helvetica Neue",Helvetica,Arial,sans-serif;
  90. font-size: 15px;
  91. /*text-shadow: 1px 1px 3px #333;*/
  92. /*box-shadow: 0 1px 0 #999;*/
  93. }
  94. .top-banner a {
  95. color: #fff;
  96. text-decoration: none;
  97. }
  98. </style>
  99. <script type="text/javascript">
  100. $(function() {
  101. $("input[id$=address]").qtip({
  102. content: '涂聚文告诉你,好样的'
  103. });
  104. });
  105. </script>
  106.  
  107. </head>
  108.  
  109. <body>
  110. <div style="width:400px;height:100px;margin:300px auto">
  111. <form>
  112. <input required='必须填写' type='text' class="name" id="name">
  113. <label alt='请输入姓名' placeholder='姓名'></label>
  114. <input required='必须填写' type='text' class="address" id="address">
  115. <label alt='请输入地址' placeholder='地址'></label>
  116.  
  117. </form>
  118. </div>
  119. <div class="footer-banner" style="width:728px; margin:200px auto 0"></div>
  120. <script src="js/jquery.min.js"></script>
  121. </body>
  122. </html>

  

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号