当前位置: 移动技术网 > IT编程>开发语言>JavaScript > JS+CSS实现炫酷光感效果

JS+CSS实现炫酷光感效果

2020年09月06日  | 移动技术网IT编程  | 我要评论
js+css带你实现炫酷光感效果,供大家参考,具体内容如下效果一:(螺旋式沉浸视觉感受)效果二:(旋涡式远观视觉感受)实现代码:<!doctype html><html> &l

js+css带你实现炫酷光感效果,供大家参考,具体内容如下

效果一:(螺旋式沉浸视觉感受)

效果二:(旋涡式远观视觉感受)

实现代码:

<!doctype html>
<html>
 <head>
 <meta charset="utf-8">
 <title>光感效果</title>
 </head>
 <style>
 html,body{
  height: 100%;
  overflow: hidden;
 }
 body{
  background-color: #c08eaf;
 }
 .main{
  /* 中心点 */
  width: 8px;
  height: 8px;
  /* background-color: aqua; */
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  /* 
  *景深,修改此属性可获得如上图展示的不同效果
  *如:图一的perspective为400px
  *图二的perspective为800px
  *修改为其它值还可获得更多效果
  */
  perspective: 800px;
 }
 .main i{
  /* 动点 */
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background:white;
  box-shadow: 0 0 10px 0 white;
  position: absolute;
  /* 动画 */
  animation: run 3s ease-in-out infinite;
 }
 /* .main i:nth-child(1){
  transform: rotate(0deg) translatex(80px);
 } */
 
 /* 动画 */
 @keyframes run{
  0%{
  opacity: 0;
  }
  10%{
  opacity: 1;
  }
  100%{
  opacity: 1;
  /* 3d动画效果 */
  transform: translate3d(0,0,560px);
  }
 }
 </style>
 <body>
 <div class="main" id="main">
 </div>
 </body>
 <script type="text/javascript">
 //获取元素
 var m = document.getelementbyid("main");
 for(var i = 0;i<60;i++){
  //创建元素
  var newnode = document.createelement("i");
  //添加元素
  m.appendchild(newnode)
  //设置旋转角度 及x轴方向位移距离
  newnode.style.transform=`rotate(${i*12}deg) translatex(80px)`
  //设置动画延迟
  newnode.style.animationdelay=`${i*0.05}s`
 }
 </script>
</html>

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

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网