SlideShare a Scribd company logo
1 of 37
CSS3 动画浅析
CDG企业发展事业群053在线支付部设计中心页面重构组
lilaczhu(朱雪青)
何为3D?
三围? 三维?
3D坐标系
3D-哪些基本动作?
基本动作 2D 3D
translate(移动)
rotate(旋转)
scale(缩放)
skew(斜切)
DIY一张立体贺卡
材料:卡片两张、剪刀、胶水
效果:卡片主内容像剪纸一样从卡片上翻转起来
Step 1
@keyframes flip-in{
0%{transform:rotate ( );}
100%{transform:rotate ( );}
}
X
X
90deg
0deg
没有透视,不成3D
perspective:
设置镜头到元素平面的距离
所有元素默认都放置在z=0的平面——即屏幕上
镜头=眼睛
图示1
原图
rotateY(30deg)
perspective:200px
rotateY(30deg)
图示2
perspective究竟设多少合适?
1680 * 1.2 ≈ 2000px
perspective-origin:
规定镜头在平面上的位置
默认放在元素的中心
图示1:
perspective:200px
perspective-origin:150px 150px
rotateY(30deg)
图示2
perspective:200px
rotateY(30deg)
原图
Step 2
.card{
perspective:2000px;
perspective-origin:150px 150px;
}
想绕图片的底边线旋转?
transform-origin:
动画作用于元素的位置
默认放在元素的中心
Step 3
.card-cont{
transform-origin:50% 100%;
}
一叶障目 不见泰山
perspective
translateZ
固定 perspective:500px
改变 translateZ:
0 -500px499px
原
始
大
小
渐
远
渐
小
不
见
泰
山
一
叶
障
目
≥500px
消
失
于
视
野
舞台在哪儿?
.wrap {perspective:500px;}
.card {transform:rotateY(60deg);}
.card {
transform:perspective(500px) rotateY(60deg);
}
写法2:透视设置每个动画元素上
写法1:透视设在动画元素公共的祖先元素上
写法2视觉效果:
写法1视觉效果:
 设在祖先元素上,则以整个祖先元素为舞台,
整体进行透视
 设在动画元素上,则以每个动画元素为舞台,
分别进行透视
scaleZ-如何缩放?
scaleX缩放宽度width,scaleY缩放高度height
而元素没有厚度(≈0),scaleZ当如何处理?
.card-bg{
transform:translateZ(-200px);
}
.card-bg{
transform:scaleZ(2) translateZ(-100px);
}
=
.card {perspective:200px;}
.card-bg {transform:scaleZ(2) rotateY(30deg);}
=
.card {perspective:100px;}
.card-bg {transform:rotateY(30deg);}
So……
scaleZ缩放的不是厚度,而是效果
参考资料:
http://www.w3schools.com/css/css3_3dtransforms.asp
http://www.alloyteam.com/2012/10/the-css3-transform-
perspective-property/
http://www.zhangxinxu.com/wordpress/2012/09/css3-3d-
transform-perspective-animate-transition/
Css3 3 d动画浅析

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Css3 3 d动画浅析

Editor's Notes

  1. 做过css3动画的举个手? 做过css3 3D动画的举个脚?有没遇到什么困难,难点在哪儿? 本分享内容来自网上资料的搜集
  2. 3D比2D多出来的是哪D? 多了一条轴,两个面
  3. CSS3 3D动画能完成哪些基本动作? 与2D相比: Translate:多了z轴方向的 Rotate:多了绕x轴和y轴的 Scale:z轴方向的缩放比较纠结,后面详讲(x、y轴均为宽、高的缩放,但z轴厚度趋近于0,如何缩放?效果缩放?) Skew:不支持
  4. 抢答:什么动画效果
  5. 没有3D效果,为什么?引出透视
  6. 比如perspective(500px)表示,镜头距离元素表面的位置是500像素。此时你看该元素,就好像你的眼睛距离该元素500像素远时看到的效果。
  7. 镜头模拟的是眼睛,那么,眼睛距屏幕有多远,是不是透视距离就该为多少呢?答案是肯定的。 鉴于目前主流的屏幕分辨率在1680*1050上下,而眼睛距离显示器的距离大约为1.2个显示器的宽度,故透视距离大致应设为1680px*1.2=2016px≈2000px。 理论值,实际一般设置得要小些。
  8. 接近500px时,一叶障目不见泰山 大于500px时,消失,因元素跑到眼睛后面了
  9. 接近500px时,一叶障目不见泰山 大于500px时,消失,因元素跑到眼睛后面了
  10. 注意: 1、写在父元素和写在子元素上时,perspective写法不同; 2、写在子元素上时,perspective必须在rotate的前面,不然透视不生效(至少chrome下如此)。
  11. 建议透视设在父元素上