css写一个放大镜如何绕着一个圆转圈

html-css022

css写一个放大镜如何绕着一个圆转圈,第1张

方法/步骤分步阅读

1

/6

打开编辑器。

2

/6

创建html文档。

3

/6

创建css文档。

4

/6

添加动画。

5

/6

加上旋转角度就会开始旋转。

6

/6

完善一下时间即可完成。

原理就是,先定义一个元素 ,然后定义动画XYZ轴偏移。

body > div > div:after {

    content: ""

    position: absolute

    top: -5px

    box-shadow: 0 0 12px #fff

    left: 50%

    margin-left: -5px

    width: 5px

    height: 5px

    border-radius: 50%

    background-color: #fff

    -webkit-animation: particle_ 2s infinite linear

    animation: particle_ 2s infinite linear

} body > div:nth-of-type(4) > div, body > div:nth-of-type(4) > div:after {

    -webkit-animation-delay: -1.5s

    animation-delay: -1.5s

}

body > div > div {

    width: 200px

    height: 200px

    position: relative

    -webkit-transform-style: preserve-3d

    -webkit-animation: trail_ 2s infinite linear

    transform-style: preserve-3d

    animation: trail_ 2s infinite linear

}

实施步骤:

建立一个BOX

在BOX中制作一个元素。

CSS动画定义BOX旋转按照你的轨迹。

通过。

-webkit-transform:rotateY( 0deg ) rotateZ( 0deg )  rotateX( 0deg )

         -moz-transform:rotateY( 0deg ) rotateZ( 0deg ) rotateX( 0deg )

      -o-transform:rotateY( 0deg ) rotateZ( 0deg ) rotateX( 0deg )

              transform:rotateY( 0deg ) rotateZ( 0deg ) rotateX( 0deg )

来定义旋转方向,0是不旋转。0-360度是一圈。

       -webkit-transition:transform 1s

transition:transform 1s

这是设置动画时间。

一个BOX完成后,复制box,摆在统一中心点后,设置Z轴的数字。

css实现圆环旋转加载

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>css实现圆环旋转加载</title>

<style>

*{

margin:0

padding:0

}

#outbox{

position:relative/*相对定位*/

width:100px/*宽度100px*/

height:100px/*高度100px*/

background:orange/*背景色橙色*/

border-radius:50%/*圆角50%*/

margin:100px/*外侧边距100px*/

}

#outbox::before{/*前置伪元素*/

content:""/*内容空*/

display:block/*块元素*/

position:absolute/*绝对定位*/

width:80px/*宽度80px*/

height:80px/*高度80px*/

left:10px/*左边距10px*/

top:10px/*距离顶部10px*/

border-radius:50%/*圆角50%*/

background:white/*背景色白色*/

}

#outbox::after{/*后置伪元素*/

content:""/*内容为空*/

display:block/*转为块元素*/

position:absolute/*绝对定位*/

width:100px/*宽度100px*/

height:100px/*高度100px*/

top:0/*距离父容器顶部边距0*/

left:0/*距离入容器左边距0*/

border-radius:50%/*圆角50%*/

background:white/*背景色白色*/

animation:myfirst 1s both linear infinite/*绑定动画。为了看清楚效果,设置动画反复执行。使用的时候只执行一次就好了*/

-webkit-animation:myfirst 1s both linear infinite/* Safari and Chrome */

}

@keyframes myfirst/*动画开始*/

{

0%{

-webkit-clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 0, 100% 0)/*不裁剪的初始效果*/

clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 0, 100% 0)

}

40%{

-webkit-clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 0, 0 0)/*裁剪四分之一*/

clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 0, 0 0)

}

60%{

-webkit-clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 100%, 0 100%)/*裁剪四分之二*/

clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 100%, 0 100%)

}

90%{

-webkit-clip-path: polygon(50% 50%, 100% 0, 100% 100%, 100% 100%, 100% 100%, 100% 100%)/*裁剪四分之三*/

clip-path: polygon(50% 50%, 100% 0, 100% 100%, 100% 100%, 100% 100%, 100% 100%)

}

100%{

-webkit-clip-path: polygon(50% 50%, 100% 0, 100% 100%, 100% 0, 100% 0, 100% 0)/*裁剪四分之四*/

clip-path: polygon(50% 50%, 100% 0, 100% 100%, 100% 0, 100% 0, 100% 0)

}

}

</style>

</head>

<body>

<div id="outbox"></div>

</body>

</html>

<!--裁剪比较粗糙,如果要更顺滑,可以裁剪得更细腻一点,比如裁剪十分之一,十分之二,十分之三,以此类推一直到十分之十。-->