css钻石旋转实现
css钻石旋转实现:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
/* 钻石旋转
* 要实现这个钻石旋转: 首先需要明确这个钻石分为上下两个部分,上面包含六个正三角形,下面有6个倒三角形
* css实现正三角形:上右下左的方向 border-style: solid;border-color:transparent;border-width: 0 50px 170px 50px; border-bottom-color: rgba(255,0,0,0.5)
* css实现倒三角形:上右下左的方向 border-style: solid;border-color:transparent;border-width: 170px 50px 0 50px; border-top-color: rgba(255,0,0,0.5)
* 然后提供一个3D环境,给外层盒子添加 transform-style: preserve-3d;flat 所有的子元素在2D平面中;preserve-3D 所有的子元素 在3D 平面中
* 上面的三角形设置为绝对定位 absolute
* 使用css3的transform 三角形按角度转动 排列成钻石的上半部分,同理实现下半部分
* rotateY:沿着Y轴实现旋转,translateZ:沿着Z轴移动88px;沿着X轴 旋转31度
* 写一个动画tuoluo 0~50%~100% 沿着z轴旋转
* 实现动画的循环播放animation: tuoluo 3s linear infinite; */ /*@keysframes*/
.wrap{
width: 200px;
height: 400px;
margin: 30px auto;
}
@keyframes tuoluo{
0%{
transform: rotateY(0deg) rotateX(0deg);
}
50%{
transform: rotateY(-180deg) rotateX(18deg);
}
100%{
transform: rotateY(-360deg) rotateX(0deg);
}
}
.wrap .tuoluo{
width: 100%;
height: 100%;
transform-style: preserve-3d;
/* flat 所有的子元素在2D平面中*/
/* preserve-3D 所有的子元素 在3D 平面中*/
animation: tuoluo 3s linear infinite;
}
.wrap .tuoluo .tuoluo-top,
.wrap .tuoluo .tuoluo-bottom{
position: relative;
width: 100%;
height: 50%;
}
.tuoluo-top .face-top{
position: absolute;
top: 29px;
width: 0;
height: 0;
border-style: solid;
border-color: transparent;
border-width: 0 50px 170px 50px;
border-bottom-color: rgba(65,92,162,.5);
/*元素变形基点的位置*/
transform-origin: center bottom;
}
.tuoluo-top .face-top:nth-of-type(1){
transform: rotateY(0deg) translateZ(88px) rotateX(31deg);
}
.tuoluo-top .face-top:nth-of-type(2){
transform: rotateY(60deg) translateZ(88px) rotateX(31deg);
}
.tuoluo-top .face-top:nth-of-type(3){
transform: rotateY(120deg) translateZ(88px) rotateX(31deg);
}
.tuoluo-top .face-top:nth-of-type(4){
transform: rotateY(180deg) translateZ(88px) rotateX(31deg);
}
.tuoluo-top .face-top:nth-of-type(5){
transform: rotateY(240deg) translateZ(88px) rotateX(31deg);
}
.tuoluo-top .face-top:nth-of-type(6){
transform: rotateY(300deg) translateZ(88px) rotateX(31deg);
}
.tuoluo-bottom .face-bottom{
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-color: transparent;
border-width: 170px 50px 0 50px;
border-top-color: rgba(65,92,162,.5);
/*元素变形基点的位置*/
transform-origin: center top;
}
.tuoluo-bottom .face-bottom:nth-of-type(1){
transform: rotateY(0deg) translateZ(88px) rotateX(-31deg);
}
.tuoluo-bottom .face-bottom:nth-of-type(2){
transform: rotateY(60deg) translateZ(88px) rotateX(-31deg);
}
.tuoluo-bottom .face-bottom:nth-of-type(3){
transform: rotateY(120deg) translateZ(88px) rotateX(-31deg);
}
.tuoluo-bottom .face-bottom:nth-of-type(4){
transform: rotateY(180deg) translateZ(88px) rotateX(-31deg);
}
.tuoluo-bottom .face-bottom:nth-of-type(5){
transform: rotateY(240deg) translateZ(88px) rotateX(-31deg);
}
.tuoluo-bottom .face-bottom:nth-of-type(6){
transform: rotateY(300deg) translateZ(88px) rotateX(-31deg);
}
</style>
</head>
<body>
<div class="wrap">
<div class="tuoluo">
<div class="tuoluo-top">
<div class="face-top"></div>
<div class="face-top"></div>
<div class="face-top"></div>
<div class="face-top"></div>
<div class="face-top"></div>
<div class="face-top"></div>
</div>
<div class="tuoluo-bottom">
<div class="face-bottom"></div>
<div class="face-bottom"></div>
<div class="face-bottom"></div>
<div class="face-bottom"></div>
<div class="face-bottom"></div>
<div class="face-bottom"></div>
</div>
</div>
</div>
</body>
</html>
css钻石旋转实现的更多相关文章
- CSS之旋转立方体
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- css做旋转相册效果
css做旋转相册效果 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...
- js+css立体旋转
纯 CSS3 制作可口可乐罐 这个效果相信大家很多人看过了,纯css实现的立体可口可乐罐,看起来相当高大上~ 于是今天我这小菜鸟试着研究下,稍微遗憾的是,没有看到源码,还是直接F12吧,貌似实现也不 ...
- CSS 3D旋转 hover 后设置transform 是相对于正常位置
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- css transform旋转属性
将以下代码复制到本地就可以看到效果: <!DOCTYPE html> <html lang="en"> <head> <meta char ...
- CSS transform旋转问题
我们都知道css的transform可以让旋转多少角度:transform:rotate(90deg),但是设置后只能旋转一次,如何想让它一直旋转下去怎么办?一种是使用matrix属性获取当前tran ...
- css制作旋转风车(transform 篇)
做这个案例之前首先要大概了解CSS的transform的属性 transform 属性向元素应用 2D 或 3D 转换.该属性允许我们对元素进行旋转.缩放.移动或倾斜. 看看效果图 打开的时候自动旋转 ...
- CSS色调旋转滤镜
一 关于filter 首先看一下官方对于CSS的filter属性的定义: CSS属性将模糊或颜色偏移等图形效果应用于元素.滤镜通常用于调整图像,背景和边框的渲染. 本文主要讲的是filter中的一个属 ...
- 个人制作-css+html旋转立方体的制作
源代码: <!DOCTYPE html><html><head> <title></title> <meta charse ...
随机推荐
- linux 安装 elasticsearch
安装 Java 8 当你提前在使用 Elasticsearch,你开始寻找更好的 Java 性能和兼容性时,您可以选择安装 Oracle 的专有 Java (Oracle JDK 8). 将 Orac ...
- 树莓派 Learning 002 装机后的必要操作 --- 06 共用键鼠 之 windows和树莓派
树莓派 装机后的必要操作 - 使用Synergy软件 共用键鼠 之 windows和树莓派 我的树莓派型号:Raspberry Pi 2 Model B V1.1 装机系统:NOOBS v1.9.2 ...
- mahout过滤推荐结果 Recommender.recommend(long userID, int howMany, IDRescorer rescorer)
Recommender.recommend(uid, RECOMMENDER_NUM, rescorer); Recommender.recommend(long userID, int howMan ...
- Entity Framework Code-First(12):Configure One-to-Many
Configure One-to-Many Relationship: Here, we will learn how to configure One-to-Many relationship be ...
- MySQL 文件导入出错
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot exec ...
- Redis源码分析-底层数据结构盘点
前段时间翻看了Redis的源代码(C语言版本,Git地址:https://github.com/antirez/redis), 过了一遍Redis数据结构,包括SDS.ADList.dict.ints ...
- 通过Python调用Spice-gtk
序言 通过Virt Manager研究学习Spice gtk的Python方法 你将学到什么 Virt Manager研究 显示代码定位 首先我们使用Virt Manager来观察桌面连接窗口 然后我 ...
- 【数据库】SQL注入攻击
背景: 机房收费系统验收的时候,师父提到SQL注入攻击.自己以前看过类似的博客大概知道一些这方面的事情,于是自己动手查了查. 定义: 所谓SQL注入,通过SQL命令插入到Web表单提交或者输入域名或页 ...
- hdu6070(分数规划/二分+线段树区间更新,区间最值)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6070 题意: 给出一个题目提交序列, 从中选出一个正确率最小的子串. 选中的子串中每个题目当且仅当最 ...
- 2017-10-15 NOIP模拟赛
Stack #include<iostream> #include<cstdio> #define mod 7 using namespace std; ][],n; int ...