• 七夕小案例:用代码给心爱的她画一个爱心


    一、爱心示例:

    二、开始写代码:

    1. /*
    2. * Hi。宝贝!
    3. * 这么久了。还没和宝贝说过我的工作呢!
    4. * 我是个前端工程师。俗称程序员。网页相关。
    5. * 如这个页面。就是个什么也没有的网页。
    6. * 我的工作就是给这种空白的页面加点儿东西。
    7. * 嗯。说起来手机和电脑还得区分一下。
    8. * 你现在用的是。。。电脑
    9. */
    10. /* 首先给所有元素加上过渡效果 */
    11. * {
    12. -webkit-transition: all .5s;
    13. transition: all .5s;
    14. }
    15. /* 白色背景太单调了。来点背景 */
    16. body, html {
    17. color: #fff;
    18. background-color: darkslategray;
    19. }
    20. /* 文字太近了 */
    21. .styleEditor {
    22. overflow: auto;
    23. width: 48vw;
    24. height: 96vh;
    25. border: 1px solid;
    26. font-size: 14px;
    27. line-height: 1.5;
    28. padding: 10px;
    29. }
    30. /* 这些代码颜色都一样。加点儿高亮区别来 */
    31. .token.selector{ color: rgb(133,153,0) }
    32. .token.property{ color: rgb(187,137,0) }
    33. .token.punctuation{ color: yellow }
    34. .token.function{ color: rgb(42,161,152) }
    35. .token.comment{ color: rgb(177,177,177) }
    36. /* 加个 3D 效果 */
    37. html{
    38. perspective: 1000px;
    39. -webkit-perspective: 1000px;
    40. }
    41. .styleEditor {
    42. transform: rotateY(10deg) translateZ(-100px) ;
    43. -webkit-transform: rotateY(10deg) translateZ(-100px);
    44. }
    45. /*
    46. * 宝贝,今天教你写代码。
    47. * 用代码画一个爱心。
    48. */
    49. /* 首先,来一个画板 */
    50. .heartWrapper {
    51. width: 48vw;
    52. height: 96vh;
    53. position: relative;
    54. border: 1px solid;
    55. background-color: white;
    56. transform: rotateY(-10deg) translateZ(-100px);
    57. -webkit-transform: rotateY(-10deg) translateZ(-100px);
    58. }
    59. /* 画一个方块,当左心室和右心室 */
    60. .heart {
    61. width: 100px;
    62. height: 100px;
    63. position: absolute;
    64. top: 50%;
    65. left: 50%;
    66. margin: -50px 0 0 -50px;
    67. border-radius: 20px;
    68. background: #E88D8D;
    69. transform: rotate(45deg);
    70. }
    71. /* 画上左心房 */
    72. .heart::before {
    73. content: '';
    74. background: #E88D8D;
    75. border-radius: 50%;
    76. width: 100px;
    77. height: 100px;
    78. position: absolute;
    79. left: -38px;
    80. top: 1px;
    81. }
    82. /* 再画上右心房 */
    83. .heart::after {
    84. content: '';
    85. background: #E88D8D;
    86. border-radius: 50%;
    87. width: 100px;
    88. height: 100px;
    89. position: absolute;
    90. right: -1px;
    91. top: -38px;
    92. }
    93. /* 太单调了,让心跳动起来 */
    94. @keyframes throb {
    95. 0% {
    96. transform: scale(1) rotate(45deg);
    97. opacity: 1;
    98. }
    99. 100% {
    100. transform: scale(1.65) rotate(45deg);
    101. opacity: 0
    102. }
    103. }
    104. .bounce {
    105. opacity: 0.2;
    106. animation: throb 1s infinite linear;
    107. }
    108. /*
    109. * Ok,完成!
    110. * 宝贝,七夕快乐!
    111. */

     三、效果示例如下:

    四、手机扫描查看真实效果:

     

     

  • 相关阅读:
    支付宝小程序关键词优化:引领数字商业的未来
    实验三 利用flask框架和Echarts实现电影榜单可视化
    Blazor和Vue对比学习(基础1.2):模板语法和Razor语法
    Microsoft Edge不能工作了,可能原因不少,那么如何修复呢
    MySQL数据同步&归档使用工具总结
    经过打包后运行app.exe文件之后问题解决
    MySQL 由于 Java 日期 LocalDateTime 数据精度引发的线上问题
    六、项目实战---识别猫和狗
    Jmeter响应时间和tps监听器使用教程
    第17章 标准库特殊设施【C++】
  • 原文地址:https://blog.csdn.net/xun527/article/details/126153547