赞
踩
1.添加实现代码
在/themes/next/layout/ _custom/ 路径下新建cube-hollow.swig文件
添加如下内容
<style> /*最外层容器样式*/ .wrap { width: 0px; height: 0px; /*margin: 80px;*/ /*position: relative;*/ position: fixed; /*显示位置*/ bottom: 80px; right: 80px; z-index: 999; } /*包裹所有容器样式*/ .cube { width: 0px; height: 0px; margin: 0 auto; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; transform: rotateX(-30deg) rotateY(-80deg); animation: rotate linear 10s infinite; } @-webkit-keyframes rotate { from { transform: rotateX(0deg) rotateY(0deg); } to { transform: rotateX(360deg) rotateY(360deg); } } .cube div { position: absolute; /*显示大小*/ width: 50px; height: 50px; opacity: 0.8; transition: all .4s; } /*定义所有图片样式*/ .pic { width: 50px; height: 50px; } .cube .out_front { transform: rotateY(0deg) translateZ(25px); } .cube .out_back { transform: translateZ(-25px) rotateY(180deg); } .cube .out_left { transform: rotateY(-90deg) translateZ(25px); } .cube .out_right { transform: rotateY(90deg) translateZ(25px); } .cube .out_top { transform: rotateX(90deg) translateZ(25px); } .cube .out_bottom { transform: rotateX(-90deg) translateZ(25px); } /*定义小正方体样式*/ .cube span { display: block; width: 25px; height: 25px; position: absolute; top: 12px; left: 12px; } .cube .in_pic { width: 25px; height:25px; } .cube .in_front { transform: rotateY(0deg) translateZ(12px); } .cube .in_back { transform: translateZ(-12px) rotateY(180deg); } .cube .in_left { transform: rotateY(-90deg) translateZ(12px); } .cube .in_right { transform: rotateY(90deg) translateZ(12px); } .cube .in_top { transform: rotateX(90deg) translateZ(12px); } .cube .in_bottom { transform: rotateX(-90deg) translateZ(12px); } /*鼠标移入后样式*/ .cube:hover .out_front { transform: rotateY(0deg) translateZ(50px); } .cube:hover .out_back { transform: translateZ(-50px) rotateY(180deg); } .cube:hover .out_left { transform: rotateY(-90deg) translateZ(50px); } .cube:hover .out_right { transform: rotateY(90deg) translateZ(50px); } .cube:hover .out_top { transform: rotateX(90deg) translateZ(50px); } .cube:hover .out_bottom { transform: rotateX(-90deg) translateZ(50px); } </style> <div class="wrap"> <!--包裹所有元素的容器--> <div class="cube"> <!--前面图片 --> <div class="out_front"> <a onclick="back2top()"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/5.jpg" class="pic" /> </a> </div> <!--后面图片 --> <div class="out_back"> <a onclick="back2top()"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/5.jpg" class="pic" /> </a> </div> <!--左面图片 --> <div class="out_left"> <a onclick="back2top()"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/5.jpg" class="pic" /> </a> </div> <!--右面图片 --> <div class="out_right"> <a onclick="back2top()"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/5.jpg" class="pic" /> </a> </div> <!--上面图片 --> <div class="out_top"> <a onclick="back2top()"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/5.jpg" class="pic" /> </a> </div> <!--下面图片 --> <div class="out_bottom"> <a onclick="back2top()"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/5.jpg" class="pic" /> </a> </div> <!--小正方体 --> <span class="in_front"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/6.jpg" class="in_pic" /> </span> <span class="in_back"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/6.jpg" class="in_pic" /> </span> <span class="in_left"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/6.jpg" class="in_pic" /> </span> <span class="in_right"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/6.jpg" class="in_pic" /> </span> <span class="in_top"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/6.jpg" class="in_pic" /> </span> <span class="in_bottom"> <img src="https://raw.githubusercontent.com/Joshua-li-yi/blog_images/master/images/first_1/6.jpg" class="in_pic" /> </span> </div> </div> <script> function back2top(){ $('html, body').animate({scrollTop: 0}, 500); } </script>
其中的照片最好放自己的鸭!
还有就是记得调整显示的位置哦!
这样基本小魔方的实现代码就写辽
2.调用
下面就是在个人主页中调用小魔方辽
在 /themes/next/layout/_custom/custom.swig 文件中引入新建的文件
<!-- 旋转魔方 -->
{% if theme.cube.enable %}
{% if theme.cube.type == "mini" %}
{% include 'cube-mini.swig' %}
{% elseif theme.cube.type == "hollow" %}
{% include 'cube-hollow.swig' %}
{% endif %}
{% endif %}
在主题next中的 _config.yml 中新添加以下动态配置项
cube:
enable: true
type: hollow # mini | hollow
这样子就好辽
最后再在gitbush中hexo g && hexo d
就可
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。