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

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

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

查看所有标签

猜你喜欢:

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

计算机系统基础

计算机系统基础

袁春风 / 机械工业出版社 / 2014-7-1 / CNY 49.00

《计算机类专业系统能力培养系列教材:计算机系统基础》主要介绍与计算机系统相关的核心概念,解释这些概念如何相互关联并最终影响程序执行的结果和性能。共分8章,主要内容包括数据的表示和运算、程序的转换及机器级表示、程序的链接、程序的执行、存储器层次结构、虚拟存储器、异常控制流和I/O操作的实现等。内容详尽,反映现实,概念清楚,通俗易懂,实例丰富,并提供大量典型习题供读者练习。本书可以作为计算机专业本科或......一起来看看 《计算机系统基础》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

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

RGB CMYK 互转工具