css 3d box 实现的一些注意事项
Test1.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
.wrap{
margin: 50px auto;
width: 200px;
padding: 200px;
perspective: 800px;
border: 1px dashed #333;
}
.box{
position: relative;
width: 200px;
height: 200px;
line-height: 200px;
font-size: 100px;
text-align: center;
color: #fff;
font-weight: bold;
border: 1px dashed #ccc;
transform-style: preserve-3d;
transform-origin: center center -100px;/*定位的方式,旋转中心点这样设置,但存在兼容性问题*/
transition: 1s;
}
.box div{
position: absolute;
width: 200px;
height: 200px;
}
.box div:nth-of-type(1){
top: -200px;
background-color: red;
transform-origin: bottom;
transform: rotateX(90deg);
}
.box div:nth-of-type(2){
left: -200px;
background-color: green;
transform-origin: right;
transform: rotateY(-90deg);
}
.box div:nth-of-type(3){
background-color: blue;
}
.box div:nth-of-type(4){
right: -200px;
background-color: #333;
transform-origin: left;
transform: rotateY(90deg);
}
.box div:nth-of-type(5){
bottom: -200px;
background-color: yellow;
transform-origin: top;
transform: rotateX(-90deg);
}
.box div:nth-of-type(6){
background-color: tan;
transform: translateZ(-200px) rotateX(180deg);
}
.wrap:hover .box{
transform: rotateX(360deg);
}
</style>
</head>
<body>
<div class="wrap">
<div class="box">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</div>
</body>
</html>
Test2.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
.wrap{
margin: 50px auto;
width: 200px;
padding: 200px;
perspective: 800px;
border: 1px dashed #333;
}
.box{
position: relative;
width: 200px;
height: 200px;
line-height: 200px;
font-size: 100px;
text-align: center;
color: #fff;
font-weight: bold;
border: 1px dashed #ccc;
transform-style: preserve-3d;
transform-origin: center center -100px;/*定位的方式,旋转中心点这样设置,但存在兼容性问题*/
transition: 1s;
}
.box div{
position: absolute;
width: 200px;
height: 200px;
}
.box div:nth-of-type(1){
top: -200px;
background-color: red;
transform-origin: bottom;
transform: rotateX(90deg);
}
.box div:nth-of-type(2){
left: -200px;
background-color: green;
transform-origin: right;
transform: rotateY(-90deg);
}
.box div:nth-of-type(3){
background-color: blue;
}
.box div:nth-of-type(4){
right: -200px;
background-color: #333;
transform-origin: left;
transform: rotateY(90deg);
}
.box div:nth-of-type(5){
bottom: -200px;
background-color: yellow;
transform-origin: top;
transform: rotateX(-90deg);
}
.box div:nth-of-type(6){
background-color: tan;
transform: translateZ(-200px) rotateX(180deg);
}
.wrap:hover .box{
transform: rotateX(360deg);
}
</style>
</head>
<body>
<div class="wrap">
<div class="box">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</div>
</body>
</html>
Test3.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
/*不用麻烦设置left,top等值*/
.wrap{
margin: 0 auto;
width: 200px;
height: 200px;
padding: 200px;
border: 1px solid #333;
perspective: 800px;/*!!!*/
}
.box{
width: 200px;
height: 200px;
position: relative;
transform-style: preserve-3d;/*!!!*/
transition: 3s all;
transform: translateZ(-100px) rotateX(0);
}
.box div{
width: 200px;
height: 200px;
line-height: 200px;
color: #fff;
position: absolute;
font-size: 100px;
text-align: center;
}
.box div:nth-of-type(1){
background-color: red;
transform: translateZ(100px);
}
.box div:nth-of-type(2){
background-color: blue;
transform-origin: top;
transform: translateZ(-100px) rotateX(90deg);/*!!!先移到最里面再操作能保证数字是正的,然后再向前移动,然后再控制其父向后移动*/
}
.box div:nth-of-type(3){
background-color: yellow;
transform: translateZ(-100px) rotateX(180deg);/*!!!*/
}
.box div:nth-of-type(4){
background-color: green;
transform-origin: bottom;
transform: translateZ(-100px) rotateX(-90deg);/*!!!*/
}
.wrap:hover .box{
transform: translateZ(-100px) rotateX(270deg);
}
</style>
</head>
<body>
<div class="wrap">
<div class="box">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
</div>
</body>
</html>
css 3d box 实现的一些注意事项的更多相关文章
- Intro to CSS 3D transforms
原文地址:Intro to CSS 3D transforms,本文只是翻译了其中的一部分,省去了作者写文章的原因浏览器兼容部分(已经过时) Perspective 元素需要设置需要设置perspec ...
- 从css 3d说到空间坐标轴
有一次我们说到掷骰子那个游戏,当时是用了一个steps属性+雪碧图来制作帧动画,这当然颇为不错,但其实一开始我想的不是这样的,我想的是用真的3d和动画去做,这个方案涉及到不少空间的知识,今天来给大伙好 ...
- css 3D动画
一.今天让我们来学习一下css 3D吧! 1.首先我们要学习好css3 3d一定要有一定的立体感! 2.再来那就聊聊原理吧! 3.css3 3d 顾名思义是由两个2d名片组成的 但不是让你建立连个2d ...
- CSS 3D 的魅力
作者 | 子慕大诗人 来源 | www.cnblogs.com/1wen/p/9064011.html 前言: 最近玩了玩用css来构建3D效果,写了几个demo,所以博客总结一下. 在阅读 ...
- 奇思妙想 CSS 3D 动画 | 仅使用 CSS 能制作出多惊艳的动画?
本文将从比较多的方面详细阐述如何利用 CSS 3D 的特性,实现各类有趣.酷炫的动画效果.认真读完,你将会收获到: 了解 CSS 3D 的各种用途 激发你新的灵感,感受动画之美 对于提升 CSS 动画 ...
- CSS 3D的魅力
用户1093975发表于Web项目聚集地订阅 151 在这篇文章中: 前言: demo1 demo2 结语: 本文介绍了CSS来实现3D效果,并且有详细代码和解释.建议大家只字不差的阅读.本文的作者是 ...
- 一个简单的CSS3+js 实现3D BOX
<!doctype html><html><head> <meta charset="UTF-8"> <title>Do ...
- Codrops 优秀教程:CSS 3D Transforms 实现书本效果
这个使用 CSS 3D Transforms 实现创意书本效果的来自 Codrops 网站.你可以看到两种类型的书设计:精装书和平装书.这两个效果都可以很容易地使用 CSS 修改.赶紧体验一下吧. ...
- 探究 CSS 混合模式\滤镜导致 CSS 3D 失效问题
今天在写一个小的 CSS Demo,一个关于 3d 球的旋转动画,关于 CSS 3D,少不了会使用下面这几个属性: { transform-style: preserve-3d; perspectiv ...
随机推荐
- (六)jQuery选择器
jQuery 的选择器可谓之强大无比,这里简单地总结一下常用的元素查找方法: $("#myELement") 选择id值等于myElement的元素,id值不能重复在文档中只能有一 ...
- (一)关于jQuery的网上资源
jQuery官网: http://jquery.com/ jQuery API: http://jquery.cuishifeng.cn/ w3school学习网站:http://www.w3scho ...
- 程序猿的量化交易之路(32)--Cointrade之Portfolio组合(19)
转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://cloudtrade.top/ Portfolio:组合,代表的是多个 ...
- java 表示当前时间的第二天的几点
Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.DAY_OF_YEAR, 1); ...
- Java异常 - Exception总结
这篇blog总结的比较详细了. 如下图所示,在Java中所有异常的基类均为Throwable类.有两个子类,分别为Exception和Error.其中Error主要由JVM处理,比如OutOfMemo ...
- python学习(十四)面向对象
Python中的面向对象,先写类,会生成类对象,类对象然后创建对象,对象就可以拿来用了. Python支持多重继承. class语句创建类对象,并将其赋值给变量名. class语句内的赋值语句会创建类 ...
- 地上有一个m行和n列的方格。一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。但是,它不能进入方格(35,38),因为3+5+3+8 = 19。请问该机器人能够达到多少个格子?
// test20.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> #include< ...
- 如何运用spring将dao注入到servlet中?
1.servlet的init方法 public void init(ServletConfig config) throws ServletException { super.init(config) ...
- linux环境tomcat配置及hadoop 2.6伪分布模式安装配置
一.ubuntu 15.04.openjdk1.7.tomcat7环境配置 1. 配置openjdk1.7,输入命令: -jdk 2. 查看java是否安装成功,输入命令: envjava -vers ...
- java多线程那些事之中的一个
1. Callable 接口 获取线程运行状态(get.get(long timeout)),取消线程(cancel(boolean mayinterruptifrunning)).isCance ...