*新闻详情页*/>
下面以2017年新年祝愿语为例给大伙儿展现下实际效果。
纯CSS3完成的电脑鼠标悬停时边框转动的实际效果:
完成编码以下,编码中注解早已较为详尽,就已不多说了:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF⑻"> <title>Document</title> <style type="text/css"> body { width: 40rem; height: 30rem; font-size: 62.50%; /* 把body的字体样式设定为10px以便捷应用rem时的测算 */ } .container { width: 100%; height: 100%; background: #0f0; text-align: center; } /* 设定content元素的特性 */ /* 此元素的宽和高务必相同,即设定border-radius: 50%;后应当是1个圆 */ /* 应用rem相对body的字体样式规格设定了宽和高 */ .content { display: inline-block; margin-top: 5rem; width: 20rem; height: 20rem; border: solid 15px rgba(255, 255, 255, 1); /* 此处设定边框,应用rgba的方法是以便后边掩藏时便捷,只必须设定a的值为0便可掩藏 */ border-radius: 50%; box-sizing: border-box; /* 应用此特性避免边框撑开盒子,border-box会让边框占有盒子里边的室内空间 */ transition: all 2s; /* 该元素的全部特性的转变会在2s内进行 */ } /* 应用伪类before设定必须旋转的边框 */ /* 由于假如元素边框旋转,內容也会跟随旋转 */ /* 此处要的实际效果是仅有边框旋转而內容不旋转 */ .content:before { display: inline-block; width: 100%; height: 100%; border-radius: 50%; box-sizing: border-box; content: ''; } /* 设定电脑鼠标悬停在content元素上时content特性的转变 */ .content:hover { /*border: solid 15px rgba(255, 255, 255, 0);*/ } /* 设定电脑鼠标悬停在content上时content的before伪类特性的转变 */ .content:hover:before { border: dashed 30px #fff; animation: whirl 9s linear infinite; /* 实行动漫whirl,实行1次的周期是9s,实行期内的速率曲线图为linear,无尽循环系统 */ } /* 设定文字內容显示信息的款式 */ .con-text { margin: ⑹0% auto; width: 80%; font-size: 3rem; /* 下列3个特性以便让文本超过宽度时显示信息省略号,务必另外应用才合理果 */ overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } /* 动漫whirl,从0度转动到360度 */ @keyframes whirl { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } </style> </head> <body> <section class="container"> <div class="content" title="新年好新年好新年好"> <p class="con-text">新年好新年好新年好</p> </div> </section> </body> </html>
以上所述是网编给大伙儿详细介绍的纯CSS3制做的电脑鼠标悬停时边框转动,期待对大伙儿有一定的协助,假如大伙儿有任何疑惑请给我留言,网编会立即回应大伙儿的。在此也十分谢谢大伙儿对脚本制作之家网站的适用!
Copyright © 2002-2020 制作小程序_小程序商城_扫码点餐小程序_微信小程序开店的步骤_牛刀小程序 版权所有 (网站地图) 粤ICP备10235580号