• 每日分享html之2个悬停、2个加载、1个button


    我是c站的一个小博主,近期我会每天分享前端知识包括(原生的web语句,以及vue2和vue3,微信小程序的写法及知识点)本篇文章收录于html特效专栏中,如果想每天在我这学到一些东西,请关注我并订阅专栏,每天都分享前端知识哦~

    欢迎关注b站:小淼前端

    有更多的前端特效,及视频讲解+源代码可领取哦~

    欢迎关注b站:小淼前端

    有更多的前端特效,及视频讲解+源代码可领取哦~

    目录

    我是c站的一个小博主,近期我会每天分享前端知识包括(原生的web语句,以及vue2和vue3,微信小程序的写法及知识点)本篇文章收录于html特效专栏中,如果想每天在我这学到一些东西,请关注我并订阅专栏,每天都分享前端知识哦~

    欢迎关注b站:小淼前端

    有更多的前端特效,及视频讲解+源代码可领取哦~

    欢迎关注b站:小淼前端

    有更多的前端特效,及视频讲解+源代码可领取哦~

    前端是做什么的?

    前端的特效视觉:

    1.纯CSS实现翻书动画

    2.莫比乌斯环loading动画

    3.上浮文字

    4.跑马灯版加载

    5.石砖墙效果button


    欢迎关注b站:小淼前端

    有更多的前端特效,及视频讲解+源代码可领取哦~

    欢迎关注b站:小淼前端

    有更多的前端特效,及视频讲解+源代码可领取哦~

    前端是做什么的?

    1.前端工程师主要利用HMTL与CSS建构页面(其中html构建骨架,css构建样式),用JavaScript获取后端数据以及完善交互以及用户体验。
    2.通俗来讲,前端在一个项目里,拿到UI设计师设计的设计稿,然后实现UI设计师设计稿,调用后端程序员给的数据接口以获取数据,然后测试,最后部署上线。
    3.前端可以对设计图负责,大部分情况下,不需要特别的去理解业务逻辑,因为我们90后都是玩着十几年手机电脑长大的,十几年的经验足够我们在潜意识里想明白应该怎么做,怎么去一步步实现,会有什么意外情况。
    4.我感觉前端发展有个很大的缺陷----晋升问题. 正如第三点所言,作为领导必须对项目有足够的了解,显然是要重点包括业务逻辑,这点上,后端开发者需要涉及数据库逻辑,是必须要跟业务逻辑打交道的(重中之重),因此,大部分的领导岗位都是后端开发者更有晋升的机会。当然,个别公司有专门的前端组长(这也不算什么),如果说前端开发者在自己工作范围之外还要腾出时间去研究业务逻辑,属实是觉得出力不讨好(因为这样的操作需要持续很久才能看出效果),而且再怎么研究业务逻辑也不会比每时每刻跟业务逻辑打交道的后端开发者了解更多。说实在的,大部分情况下,前端在配合后端进行开发.后端需要了解业务逻辑,要跟领导和客户商量细节,露脸机会很大,在老板面前刷脸次数众多。这些都是拉开前后端程序员晋升机会差距的因素。

    前端的特效视觉:

    层次结构的表现

    动态效果,如缩放,覆盖,滑出网页或单个视觉元素,可帮助用户理解网页信息架构。通常是通过转场和菜单来展开网页。

    表现层级关系

    为了展现层与层的关系,是抽屉,是打开,还是平级切换等等。让用户知道这个界面和上一个、下一个的关系。

    清晰明确

    动效可以清晰地表明各种数据块中间的逻辑结构,即使在数据高度饱和的情况下也能使一切从观感上有组织性。

    添加了图层

    在网站制作过程中加上特效,每个元素都在用户滚动页面或者是鼠标经过的地方有动态效果,就像在平面层上多出了一个动态层,这样看起来更加有层次感。

    我想借此专栏发布的内容帮助那些正在入坑前端的家人们,同时作为我以后复习的笔记,希望我们可以互相帮助,共同加油!!!

    1.纯CSS实现翻书动画

     代码:

    1. html>
    2. <html>
    3. <head>
    4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
    5. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    6. <title>纯CSS实现翻书动画title>
    7. <style>
    8. *{
    9. /* 初始化 */
    10. margin: 0;
    11. padding: 0;
    12. }
    13. body{
    14. /* 100%窗口高度 */
    15. height: 100vh;
    16. /* 弹性布局 水平+垂直居中 */
    17. display: flex;
    18. justify-content: center;
    19. align-items: center;
    20. background: #dfb88e;
    21. }
    22. .book{
    23. width: 300px;
    24. height: 400px;
    25. background-color: #fff;
    26. /* 开启3D效果 */
    27. transform-style: preserve-3d;
    28. /* 设置视距 */
    29. perspective: 2000px;
    30. /* 设置阴影 */
    31. box-shadow: inset 300px 0 30px rgba(0,0,0,0.2),
    32. 0 10px 100px rgba(0,0,0,0.3);
    33. /* 动画过渡 */
    34. transition: 1s;
    35. }
    36. /* 鼠标移入,阴影变化+旋转 */
    37. .book:hover{
    38. transform: rotate(-10deg);
    39. box-shadow: inset 20px 0 30px rgba(0,0,0,0.2),
    40. 0 10px 100px rgba(0,0,0,0.3);
    41. }
    42. .book::before{
    43. content: "";
    44. /* 绝对定位 */
    45. position: absolute;
    46. left: 0;
    47. top: -5px;
    48. width: 100%;
    49. height: 5px;
    50. background-color: #0d2a50;
    51. /* 设置旋转元素的基点位置 */
    52. transform-origin: bottom;
    53. /* 沿X轴倾斜-45度 */
    54. transform: skewX(-45deg);
    55. }
    56. .book::after{
    57. content: "";
    58. position: absolute;
    59. top: 0;
    60. right: -5px;
    61. width: 5px;
    62. height: 100%;
    63. background-color: #3d5a83;
    64. transform-origin: left;
    65. transform: skewY(-45deg);
    66. }
    67. /* 封面 */
    68. .book .cover{
    69. width: 100%;
    70. height: 100%;
    71. background-color: #2a3f5c;
    72. display: flex;
    73. justify-content: center;
    74. align-items: center;
    75. /* 相对定位 */
    76. position: relative;
    77. transform-origin: left;
    78. transition: 1s;
    79. }
    80. .book .cover span{
    81. position: absolute;
    82. right: 30px;
    83. top: 30px;
    84. background-color: #fff;
    85. font-size: 40px;
    86. font-family: "隶书";
    87. /* 竖向文本 */
    88. writing-mode: vertical-lr;
    89. padding: 10px 5px 5px 5px;
    90. /* 字间距 */
    91. letter-spacing: 5px;
    92. }
    93. .book:hover .cover{
    94. transform: rotateY(-135deg);
    95. }
    96. .book .content{
    97. width: 100%;
    98. height: 100%;
    99. position: absolute;
    100. top: 0;
    101. left: 0;
    102. z-index: -1;
    103. font-size: 40px;
    104. font-family: "隶书";
    105. line-height: 50px;
    106. letter-spacing: 5px;
    107. display: flex;
    108. flex-direction: column;
    109. justify-content: center;
    110. align-items: center;
    111. }
    112. style>
    113. head>
    114. <body>
    115. <div class="book">
    116. <div class="cover">
    117. <span>前端宝典span>
    118. div>
    119. <div class="content">
    120. <p>CSDNp>
    121. <p>lqj_本人p>
    122. div>
    123. div>
    124. body>
    125. html>

    2.莫比乌斯环loading动画

     代码:

    1. html>
    2. <html>
    3. <head>
    4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
    5. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    6. <title>莫比乌斯环loading动画title>
    7. <style>
    8. *{
    9. /* 初始化 */
    10. margin: 0;
    11. padding: 0;
    12. }
    13. body{
    14. /* 100%窗口高度 */
    15. height: 100vh;
    16. /* 弹性布局 水平+垂直居中 */
    17. display: flex;
    18. justify-content: center;
    19. align-items: center;
    20. background-color: #333;
    21. }
    22. .loader{
    23. display: flex;
    24. justify-content: center;
    25. align-items: center;
    26. /* 相对定位 */
    27. position: relative;
    28. left: 7.5px;
    29. }
    30. .loader::before,
    31. .loader::after{
    32. content: "";
    33. width: 150px;
    34. height: 150px;
    35. border-radius: 50%;
    36. border: 15px solid #57606f;
    37. box-sizing: border-box;
    38. position: relative;
    39. z-index: -1;
    40. }
    41. .loader::after{
    42. left: -15px;
    43. }
    44. .loader div{
    45. width: 150px;
    46. height: 150px;
    47. /* 绝对定位 */
    48. position: absolute;
    49. left: 0;
    50. /* 利用clip-path的方式遮盖掉下半部分 */
    51. clip-path: polygon(0 0,100% 0,100% 50%,0 50%);
    52. }
    53. .loader div div{
    54. width: 150px;
    55. height: 150px;
    56. box-sizing: border-box;
    57. border-style: solid;
    58. border-width: 15px;
    59. border-color: #00ff40 #00ffd5 transparent transparent;
    60. border-radius: 50%;
    61. /* 默认旋转135度,让圆环处于遮盖处 */
    62. transform: rotate(135deg);
    63. animation: roll 4s linear infinite;
    64. }
    65. .lb{
    66. transform: scale(-1,-1);
    67. }
    68. .rt{
    69. transform: translateX(calc(100% - 15px)) scale(-1,1);
    70. }
    71. .rb{
    72. transform: translateX(calc(100% - 15px)) scale(1,-1);
    73. }
    74. /* 接下来设置动画延迟 */
    75. .loader .rb div{
    76. animation-delay: 1s;
    77. }
    78. .loader .rt div{
    79. animation-delay: 2s;
    80. }
    81. .loader .lb div{
    82. animation-delay: 3s;
    83. }
    84. /* 定义动画 */
    85. @keyframes roll {
    86. 50%,100%{
    87. transform: rotate(495deg);
    88. }
    89. }
    90. style>
    91. head>
    92. <body>
    93. <div class="loader">
    94. <div class="lt">
    95. <div>div>
    96. div>
    97. <div class="lb">
    98. <div>div>
    99. div>
    100. <div class="rt">
    101. <div>div>
    102. div>
    103. <div class="rb">
    104. <div>div>
    105. div>
    106. div>
    107. body>
    108. html>

    3.上浮文字

    代码:

    1. html>
    2. <html>
    3. <head>
    4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
    5. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    6. <title>上浮文字title>
    7. <style>
    8. /* 引入网络字体:Poppins */
    9. @import url("http://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600,700,800,900&display=swap");
    10. *{
    11. /* 初始化 */
    12. margin: 0;
    13. padding: 0;
    14. box-sizing: border-box;
    15. /* 设置字体 */
    16. font-family: "Poppins";
    17. }
    18. body{
    19. /* 100%窗口高度 */
    20. min-height: 100vh;
    21. /* 弹性布局 水平+垂直居中 */
    22. display: flex;
    23. justify-content: center;
    24. align-items: center;
    25. background-color: #161626;
    26. }
    27. /* 给背景增加两个渐变圆 */
    28. body::before{
    29. content: "";
    30. /* 绝对定位 */
    31. position: absolute;
    32. top: 0;
    33. left: 0;
    34. width: 100%;
    35. height: 100%;
    36. /* 渐变背景 */
    37. background: linear-gradient(#2193b0,#6dd5ed);
    38. /* 将元素剪切微一个圆形【30%表示圆的直径】【right 70%表示圆心位置】 */
    39. clip-path: circle(30% at right 70%);
    40. }
    41. body::after{
    42. content: "";
    43. /* 绝对定位 */
    44. position: absolute;
    45. top: 0;
    46. left: 0;
    47. width: 100%;
    48. height: 100%;
    49. /* 渐变背景 */
    50. background: linear-gradient(#ee9ca7,#ffdde1);
    51. /* 将元素剪切微一个圆形【30%表示圆的直径】【right 70%表示圆心位置】 */
    52. clip-path: circle(20% at 10% 10%);
    53. }
    54. .container{
    55. position: relative;
    56. display: flex;
    57. justify-content: center;
    58. align-items: center;
    59. flex-wrap: wrap;
    60. z-index: 1;
    61. }
    62. .container .card{
    63. /* 相对定位 */
    64. position: relative;
    65. width: 280px;
    66. height: 400px;
    67. background-color: rgba(255,255,255,0.1);
    68. margin: 30px;
    69. border-radius: 15px;
    70. /* 阴影 */
    71. box-shadow: 20px 20px 50px rgba(0,0,0,0.5);
    72. /* 溢出隐藏 */
    73. overflow: hidden;
    74. display: flex;
    75. justify-content: center;
    76. align-items: center;
    77. border-top: 1px solid rgba(255,255,255,0.5);
    78. border-left: 1px solid rgba(255,255,255,0.5);
    79. /* 背景模糊 */
    80. backdrop-filter: blur(5px);
    81. }
    82. .container .card .content{
    83. padding: 20px;
    84. text-align: center;
    85. /* 默认下移+隐藏 */
    86. transform: translateY(100px);
    87. opacity: 0;
    88. transition: 0.5s;
    89. }
    90. .container .card:hover .content{
    91. /* 鼠标移入,上移+显示 */
    92. transform: translateY(0);
    93. opacity: 1;
    94. }
    95. .container .card .content h2{
    96. position: absolute;
    97. top: -80px;
    98. right: 25px;
    99. font-size: 128px;
    100. color: rgba(255,255,255,0.05);
    101. }
    102. .container .card .content h3{
    103. font-size: 28px;
    104. color: #fff;
    105. }
    106. .container .card .content p{
    107. font-size: 16px;
    108. color: #fff;
    109. font-weight: 300;
    110. margin: 10px 0 15px 0;
    111. }
    112. .container .card .content a{
    113. position: relative;
    114. display: inline-block;
    115. padding: 8px 20px;
    116. margin-top: 15px;
    117. background-color: #fff;
    118. color: #000;
    119. text-decoration: none;
    120. border-radius: 20px;
    121. font-weight: 500;
    122. box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    123. }
    124. /* 这里要让玻璃效果更加逼真,需要用到一个JS库:vanilla-tilt.js */
    125. /* 我事先下载好了,需要这个JS库的可以找我拿 */
    126. /* 看操作~ */
    127. style>
    128. head>
    129. <body>
    130. <div class="container">
    131. <div class="card">
    132. <div class="content">
    133. <h2>01h2>
    134. <h3>Card Oneh3>
    135. <p>Realistic glass card hover effect, realistic glass card hover effect, realistic glass card hover effect.p>
    136. <a href="#">Read Morea>
    137. div>
    138. div>
    139. <div class="card">
    140. <div class="content">
    141. <h2>02h2>
    142. <h3>Card Twoh3>
    143. <p>Realistic glass card hover effect, realistic glass card hover effect, realistic glass card hover effect.p>
    144. <a href="#">Read Morea>
    145. div>
    146. div>
    147. <div class="card">
    148. <div class="content">
    149. <h2>03h2>
    150. <h3>Card Threeh3>
    151. <p>Realistic glass card hover effect, realistic glass card hover effect, realistic glass card hover effect, realistic glass card hover effect.p>
    152. <a href="#">Read Morea>
    153. div>
    154. div>
    155. div>
    156. <script src="../js/vanilla-tilt.js">script>
    157. <script>
    158. // vanilla-tilt.js是一个平滑的3D倾斜JS库,具体参数配置度娘可查到
    159. VanillaTilt.init(document.querySelectorAll(".card"),{
    160. max: 15, //最大倾斜度数
    161. speed: 400, //倾斜转换的速度
    162. glare: true, //是否开启眩光效果
    163. "max-glare": 1 //最大眩光的不透明度
    164. })
    165. script>
    166. body>
    167. html>

    4.跑马灯版加载

     代码:

    1. html>
    2. <html>
    3. <head>
    4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
    5. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    6. <title>跑马灯版加载title>
    7. <style>
    8. *{
    9. /* 初始化 */
    10. margin: 0;
    11. padding: 0;
    12. }
    13. body{
    14. /* 100%窗口高度 */
    15. min-height: 100vh;
    16. /* 弹性布局 水平+垂直居中 */
    17. display: flex;
    18. justify-content: center;
    19. align-items: center;
    20. background-color: #000;
    21. /* 自定义属性,可通过var函数对其调用 */
    22. --c: gold;
    23. }
    24. .loader{
    25. /* 弹性布局 垂直排列 居中 */
    26. display: flex;
    27. flex-direction: column;
    28. justify-content: center;
    29. align-items: center;
    30. /* 执行颜色改变动画 */
    31. animation: changeColor 5s linear infinite;
    32. }
    33. .dot-box{
    34. display: flex;
    35. }
    36. .dot-box .dot{
    37. width: 20px;
    38. height: 20px;
    39. border-radius: 50%;
    40. /* 通过var函数调用自定义属性--c,设置颜色 */
    41. background-color: var(--c);
    42. margin: 20px 10px;
    43. /* 阴影(发光效果) */
    44. box-shadow: 0 0 10px var(--c),
    45. 0 0 20px var(--c),
    46. 0 0 40px var(--c),
    47. 0 0 60px var(--c),
    48. 0 0 80px var(--c),
    49. 0 0 100px var(--c);
    50. /* 默认缩放为0.1倍 */
    51. transform: scale(0.1);
    52. /* 设置动画:动画名 时长 线性 无限播放 */
    53. animation: dotAnimate 2s linear infinite;
    54. /* 设置每一个圆点的动画延迟时间 */
    55. animation-delay: calc(0.1s * var(--i));
    56. }
    57. .loader p{
    58. color: var(--c);
    59. font-size: 20px;
    60. font-weight: 500;
    61. letter-spacing: 5px;
    62. }
    63. .dot-box:nth-child(3) .dot{
    64. /* 设置下面一排圆点的动画延迟时间 */
    65. animation-delay: calc(-0.1s * var(--i));
    66. }
    67. /* 定义动画 */
    68. /* 圆点的动画 */
    69. @keyframes dotAnimate {
    70. 0%{
    71. /* 设置缩放 */
    72. transform: scale(0.1);
    73. }
    74. 10%{
    75. transform: scale(1);
    76. }
    77. 50%,100%{
    78. transform: scale(0.1);
    79. }
    80. }
    81. /* 颜色改变的动画 */
    82. @keyframes changeColor {
    83. 0%{
    84. /* 颜色滤镜 */
    85. filter: hue-rotate(0deg);
    86. }
    87. 100%{
    88. filter: hue-rotate(360deg);
    89. }
    90. }
    91. style>
    92. head>
    93. <body>
    94. <div class="loader">
    95. <div class="dot-box">
    96. <div class="dot" style="--i:0;">div>
    97. <div class="dot" style="--i:1;">div>
    98. <div class="dot" style="--i:2;">div>
    99. <div class="dot" style="--i:3;">div>
    100. <div class="dot" style="--i:4;">div>
    101. <div class="dot" style="--i:5;">div>
    102. <div class="dot" style="--i:6;">div>
    103. <div class="dot" style="--i:7;">div>
    104. <div class="dot" style="--i:8;">div>
    105. <div class="dot" style="--i:9;">div>
    106. div>
    107. <p>拼命加载中...p>
    108. <div class="dot-box">
    109. <div class="dot" style="--i:0;">div>
    110. <div class="dot" style="--i:1;">div>
    111. <div class="dot" style="--i:2;">div>
    112. <div class="dot" style="--i:3;">div>
    113. <div class="dot" style="--i:4;">div>
    114. <div class="dot" style="--i:5;">div>
    115. <div class="dot" style="--i:6;">div>
    116. <div class="dot" style="--i:7;">div>
    117. <div class="dot" style="--i:8;">div>
    118. <div class="dot" style="--i:9;">div>
    119. div>
    120. div>
    121. body>
    122. html>

    5.石砖墙效果button

     代码:

    1. html>
    2. <html>
    3. <head>
    4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
    5. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    6. <title>石砖墙效果title>
    7. <style>
    8. *{
    9. /* 初始化 */
    10. margin: 0;
    11. padding: 0;
    12. }
    13. body{
    14. /* 100%窗口高度 */
    15. height: 100vh;
    16. /* 弹性布局 水平+垂直居中 */
    17. display: flex;
    18. justify-content: center;
    19. align-items: center;
    20. /* 垂直排列元素 */
    21. flex-direction: column;
    22. background-color: #333;
    23. }
    24. button{
    25. margin: 10px;
    26. width: 280px;
    27. height: 90px;
    28. font-size: 35px;
    29. font-weight: bold;
    30. background: transparent;
    31. border: 1px solid transparent;
    32. /* 相对定位 */
    33. position: relative;
    34. /* 设置内阴影 */
    35. box-shadow: inset 1px 1px 2px #000,
    36. inset -1px -1px 2px #808080;
    37. color: #333;
    38. /* 文本阴影 */
    39. text-shadow: 1px 1px 0 #808080;
    40. overflow: hidden;
    41. /* 加个过渡 */
    42. transition: 0.3s linear 0.15s;
    43. }
    44. /* 分别为各个按钮设置自定义属性--c(颜色) */
    45. button:nth-child(1){
    46. --c:#ff4757;
    47. }
    48. button:nth-child(2){
    49. --c:#ffa502;
    50. }
    51. button:nth-child(3){
    52. --c:#2ed573;
    53. }
    54. button:nth-child(4){
    55. --c:#1e90ff;
    56. }
    57. /* 射灯 */
    58. button::before{
    59. content: "";
    60. /* 绝对定位 */
    61. position: absolute;
    62. width: 100px;
    63. height: 8px;
    64. top: 0;
    65. left: 50%;
    66. transform: translateX(-50%);
    67. /* background: var(--c); */
    68. border-radius: 0 0 50% 50%;
    69. /* 模糊滤镜 */
    70. filter: blur(5px);
    71. /* 设置过渡 */
    72. transition: 0.3s;
    73. }
    74. button:hover::before{
    75. /* 通过var函数调用自定义属性--c,设置射灯颜色 */
    76. background: var(--c);
    77. box-shadow: 0 0 10px var(--c),
    78. 0 0 20px var(--c),
    79. 0 0 30px var(--c),
    80. 0 0 40px var(--c),
    81. 0 0 50px var(--c);
    82. }
    83. button:hover{
    84. color: #fff;
    85. text-shadow: 0 0 10px var(--c),
    86. 0 5px 5px #000;
    87. box-shadow: inset 1px 1px 2px #000,
    88. inset -1px -1px 2px var(--c);
    89. }
    90. style>
    91. head>
    92. <body>
    93. <button>点赞button>
    94. <button>关注button>
    95. <button>收藏button>
    96. <button>评论button>
    97. body>
    98. html>

  • 相关阅读:
    python:xlrd 读取 Excel文件,显示在 tkinterTable 表格中
    Linux 下 USB 端口和设备的绑定
    IIS方式部署项目发布上线
    SQL练习 2022/7/2
    【Numpy】一篇文章讲解常用的numpy.random()函数(含Python代码理解)
    TouchGFX之Mixins
    Linux编译器-gcc/g++使用
    mysql中有isolated transaction吗举例说明
    【蓝桥杯】C语言常见高级算法
    解决 IllegalArgumentException: 代码点[26,143]处的Unicode字符[星]无法编码,因为它超出了允许的0到255范围 问题
  • 原文地址:https://blog.csdn.net/lbcyllqj/article/details/127099801