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 ...
随机推荐
- C++二叉树结构的建立和操作
二叉树是数据结构中的树的一种特殊情况,有关二叉树的相关概念,这里不再赘述,如果不了解二叉树相关概念,建议先学习数据结构中的二叉树的知识点. 准备数据 定义二叉树结构操作中需要用到的变量及数据等. #d ...
- SpringCloud01 服务提供者和消费者
说明:服务消费者直接利用RestTemplate调用服务提供者,这种使用方式只是适用于微服务数量比较少的项目,如果微服务的数量比较多建议使用SpringCloud提供的Eureaka组件. 注意:实现 ...
- day1_2_3
DD烧写命令(mfgtools-without-rootfs.tar.gz) ubuntu minicom svn 应用层进程阻塞调试 多机共享 securecrt的远程登录以及调试 tengxunt ...
- Spring入门第四课
注入参数详解:null值和级联属性 可以使用专用的<null/>元素标签为Bean的字符串或其他对象类型的属性注入null值. 和Struts,Hiberante等框架一样,Spring支 ...
- IOS 完成来电归属地
首先是一个库:(有时间在上传) 然后设置一个工具类 .h @interface HMFoundLocation : NSObject AS_SINGLETON(HMFoundLocation) @pr ...
- HBase高可用原理与实践
前言 前段时间有套线上HBase出了点小问题,导致该套HBase集群服务停止了2个小时,从而造成使用该套HBase作为数据存储的应用也出现了服务异常.在排查问题之余,我们不禁也在思考,以后再出现类似的 ...
- Fetch超时设置和终止请求
1.基本使用 Fetch 是一个新的端获取资源的接口,用于替换笨重繁琐XMLHttpRequest.它有了Request 和 Response 以及Headers对象的概念,与后端语言请求资源更接近. ...
- Linux vim常用选项
Vim命令 三种模式 Command Mode 命令模式 Insert Mode 插入模式 Last LineMode 底行模式 底行模式常用命令 :w 保存 :q 退出 :! + 命令 :! ls ...
- 反射实现数据库增删改查DAO及DAOImpl源代码(一)
这是DAO层,第一次尝试,如有bug希望能即使反馈,我们共同进步.具体的用法和实现原理我会在前面几篇博客中补充更新.配置文件及项目目录结构会在下一篇中贴出! package com.javasm.su ...
- 2017-10-4 清北刷题冲刺班p.m
P102zhx a [问题描述]你是能看到第一题的 friends 呢.——hja两种操作:1.加入一个数.2.询问有多少个数是?的倍数.[输入格式]第一行一个整数?,代表操作数量.接下来?行,每行两 ...