简单的输入框焦点动画效果

栏目: Html · 发布时间: 6年前

核心属性

::placeholder 改变输入框中占位文字的样式

:focus + width + color + text-align 鼠标点击输入框后改变它和占位文字的样式

text-indent: -9999px 隐藏按钮中的文字

:focus + display + background-size 鼠标点击输入框后出现右边的图标按钮

  1. <div class="wrapper">
  2. <div class="middle">
  3. <input type="email" value="" name="EMAIL" class="email-field" id="email-field" placeholder="输入文字">
  4. <input type="submit" value="Subscribe" name="subscribe" id="subscribe-button" class="">
  5. </div>
  6. </div>
  1. body {
  2. color: #efaa9d;
  3. background-color: #f05133;
  4. text-align: center;
  5. }
  6. ::placeholder {
  7. color: #f4f2ca;
  8. opacity: .8;
  9. }
  10. .email-field {
  11. display: inline-block;
  12. width: 80px;
  13. padding: .9em 1.8em;
  14. color: #f4f2ca;
  15. background-color: #d8492e;
  16. border: none;
  17. border-radius: 4px;
  18. outline: none;
  19. cursor: pointer;
  20. text-align: center;
  21. transition: all .1s linear;
  22. }
  23. .email-field:hover {
  24. background-color: #d0432a;
  25. }
  26. .email-field:focus {
  27. width: 200px;
  28. color: #efaa9d;
  29. outline: none;
  30. text-align: left;
  31. cursor: inherit;
  32. }
  33. #subscribe-button {
  34. display: none;
  35. width: 35px;
  36. height: 35px;
  37. border: none;
  38. background: url(https://pics.codecolor.cn/morphing-input/arrow-circle-on-right.svg) no-repeat;
  39. background-size: 13px;
  40. background-position: 0 1px;
  41. text-indent: -9999px;
  42. opacity: .25;
  43. cursor: pointer;
  44. transition: all .2s linear;
  45. }
  46. #subscribe-button:hover {
  47. opacity: .33;
  48. }
  49. .email-field:focus + #subscribe-button {
  50. display: inline-block;
  51. background-size: 33px;
  52. }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

JSP基础教程

JSP基础教程

耿祥义 / 清华大学出版社 / 2004-1 / 22.00元

《JSP基础教程:黑魔方》详细讲解了JSP语法和基本的程序设计方法。全书共分6章,内容包括JSP简介、JSP语法、JSP内置对象、JSP文件操作,以及如何在JSP中使用数据库等重要内容。《JSP基础教程:黑魔方》所有知识都结合具体实例进行介绍,力求详略得当,突出JSP在开发Web动态网站方面的强大功能及在开发商务网站方面的应用,使读者快速掌握和运用JSP的编程技巧。JSP(Java Server ......一起来看看 《JSP基础教程》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具