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

栏目: 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. }

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

查看所有标签

猜你喜欢:

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

颠覆式创新:移动互联网时代的生存法则

颠覆式创新:移动互联网时代的生存法则

李善友 / 机械工业出版社 / 2015-3-1

为什么把每件事情都做对了,仍有可能错失城池?为什么无人可敌的领先企业,却在一夜之间虎落平阳?短短三年间诺基亚陨落,摩托罗拉以区区29亿美元出售给联想,芯片业霸主英特尔在移动芯片领域份额几乎为零,风光无限的巨头转眼成为被颠覆的恐龙,默默无闻的小公司一战成名迅速崛起,令人瞠目结舌的现象几乎都能被“颠覆式创新”法则所解释。 颠覆式创新教你在新的商业竞争中“换操作系统”而不是“打补丁”,小公司用破坏......一起来看看 《颠覆式创新:移动互联网时代的生存法则》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具