css3 转换transfrom 过渡transition 和两个@

做了一个demo。用到一些css3的动画,还是不太熟练,总结了一下。

 1、 -webkit-font-smoothing: antialiased;      
  • -webkit-font-smoothing: none: 无抗锯齿
  • -webkit-font-smoothing: subpixel-antialiased | default: 次像素平滑
  • -webkit-font-smoothing: antialiased: 灰度平滑
2、    -webkit-perspective: 800px; 设置元素被查看位置的视图:
值: 元素距离视图的距离,以像素计。
使子元素又了3d的效果:
<!DOCTYPE html>
<html>
<head>
<style>
#div1
{
position: relative;
height: 150px;
width: 150px;
margin: 50px;
padding:10px;
border: 1px solid black;
-webkit-perspective:150; /* Safari and Chrome */
}
 
#div2
{
padding:50px;
position: absolute;
border: 1px solid black;
background-color: yellow;
-webkit-transform: rotateX(60deg); /* Safari and Chrome */
}
</style>
</head>
 
<body>
 
<div id="div1">
  <div id="div2">HELLO</div>
</div>
 
</body>
</html>
 
没那个,子元素会有动作但是没有3d效果
3、-webkit-transition: all .8s;
过渡属性   transition    可以设置4个属性    transition-property:规定应用过渡的 CSS 属性的名称。   transition-duration:定义效果花费的时间。默认是0   transition-timing-function   :定义过渡效果时间曲线。默认是“ease”       transition-delay:规定效果的延迟时间。默认是0 
 
可以设置四个:那个过渡(property- 性质- 财产- 财产权- 属性) 、过渡时间(持续时间duration)、过渡样式 、延迟时间
那个过渡:
none没有属性会获得过渡效果。
all所有属性都将获得过渡效果。
property定义应用过渡效果的 CSS 属性名称列表,列表以逗号分隔。
 
过渡效果:
linear规定以相同速度开始至结束的过渡效果(等于 cubic-bezier(0,0,1,1))。
ease规定慢速开始,然后变快,然后慢速结束的过渡效果(cubic-bezier(0.25,0.1,0.25,1))。
ease-in规定以慢速开始的过渡效果(等于 cubic-bezier(0.42,0,1,1))。
ease-out规定以慢速结束的过渡效果(等于 cubic-bezier(0,0,0.58,1))。
ease-in-out规定以慢速开始和结束的过渡效果(等于 cubic-bezier(0.42,0,0.58,1))。
cubic-bezier(n,n,n,n)
 
4.-webkit-transform-style: preserve-3d;
 
2D Transform 方法
  • vt. 改变,使…变形;转换
 
 
一、transform  向元素应用2d或者3d的转换
(1)2d: transform
  • transform属性可用于内联(inline)元素和块级(block)元素。它允许我们旋转、缩放和移动元素,他有几个属性值参数:
  • rotate(旋转)允许你通过传递一个度数值来转动一个对象;
  • scale是一个缩放功能,可以让任一元素变的更大。它使用一个或者两个正数和负数以及小数作为参数;当使用一个参数时表示X轴和Y轴的缩放相同;
  • translate就是基于X和Y 坐标重新定位元素,当使用一个参数时表示X轴和Y轴的参数相同;
  • skew倾斜(ps中的斜切),参数是度数,当使用一个参数时表示X轴和Y轴的参数相同;
  • matrix矩阵变换,就是基于X和Y 坐标重新定位元素,它使用6个参数
transform-origin  允许你改变被转换元素的位置
JavaScript 语法:object.style.transformOrigin="20% 40%"

 

 

 

二、改变元素基点transform-origin
  • transform-origin是变形原点,也就是该元素围绕着那个点变形或旋转,该属性只有在设置了transform属性的时候起作用;
  •  因为我们元素默认基点就是其中心位置换句话说我们没有使用transform-origin改变元素基点位置的情况下,transform进行的rotate,translate,scale,skew,matrix等操作都是以元素自己中心位置进行变化的
  • 但有时候我们需要在不同的位置对元素进行这些操作,那么我们就可以使用transform-origin来对元素进行基点位置改变,使元素基点不在是中心位置,以达到你需要的基点位置。
  • 下面我们主要来看看其使用规则:

    transform-origin(X,Y):用来设置元素的运动的基点(参照点)。默认点是元素的中心点。其中X和Y的值可以是百分值,em,px,其中X也可以是字符参数值left,center,rightY和X一样除了百分值外还可以设置字符值top,center,bottom

    • 语法:-moz-transform-origin: [ |  | left | center | right ][ |  | top | center | bottom ] ?
    • transform-origin接受两个参数,它们可以是百分比,em,px等具体的值,也可以是left,center,right,或者 top,center,bottom等描述性参数 ;
    • top left | left top 等价于 0 0;
    • top | top center | center top 等价于 50% 0
    • right top | top right 等价于 100% 0
    • left | left center | center left 等价于 0 50%
    • center | center center 等价于 50% 50%(默认值)
    • right | right center | center right 等价于 100% 50%
    • bottom left | left bottom 等价于 0 100%
    • bottom | bottom center | center bottom 等价于 50% 100%
    • bottom right | right bottom 等价于 100% 100%
 
 
其中 left,center right是水平方向取值,对应的百分值为left=0%;center=50%;right=100%
top center bottom是垂直方向的取值,其中top=0%;center=50%;bottom=100%;
如果 只取一个值,表示垂直方向值不变
注: transform-origin并不是transform中的属性值,他具有自己的语法。
但是他要结合transform才能起作用
三、CSS3 transform-style 属性
 

规定被嵌套元素如何在 3D 空间中显示。

 

 

规定被嵌套元素如何在 3D 空间中显示。

 

4、perspective 属性
 规定 3D 元素的透视效果。
5、 perspective-origin
perspective-origin 属性定义 3D 元素所基于的 X 轴和 Y 轴。该属性允许您改变 3D 元素的底部位置。
 
当为元素定义 perspective-origin 属性时,其子元素会获得透视效果,而不是元素本身。
 
注释:该属性必须与 perspective 属性一同使用,而且只影响 3D 转换元素。
6、backface-visibility 属性
backface-visibility 属性定义当元素不面向屏幕时是否可见。
1、动画  @keyframes   然后使用animation:第一个参数就行@keyframes 定义的参数

animation:[<animation-name> || <animation-duration> || <animation-timing-function> || <animation-delay> || <animation-iteration-count> || <animation-direction>] [, [<animation-name> || <animation-duration> || <animation-timing-function> || <animation-delay> || <animation-iteration-count> || <animation-direction>] ]* 

 

 

 

 

 

转载于:https://www.cnblogs.com/chenjinxinlove/p/5557184.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
@font-face{ font-family:"Raphaelicons"; src:url('fonts/raphaelicons-webfont.eot'); src:url('fonts/raphaelicons-webfont.eot?#iefix') format('embedded-opentype'), url('fonts/raphaelicons-webfont.ttf') format('truetype'), url('fonts/raphaelicons-webfont.woff') format('woff'), url('fonts/raphaelicons-webfont.svg') format('svg'); font-weight: normal; font-style: normal; } html,body,.container,.st-container{ height: 100%; } body{ font-family:Arial,Georgia,serif; background-color: #ddd; font-weight: bold; font-size: 15px; color: #333; overflow: hidden; -webkit-font-smoothing:antialiased; } a{ text-decoration: none; color: #555; } .clr{ width: 0; height: 0; overflow: hidden; clear: both; padding:0; margin:0; } .st-container{ width: 100%; height: 100%; position: absolute;; top:0; left:0; font-family: Arial,"Josefin Slab","Myriad Pro",sans-serif; } .st-container > input,.st-container > a{ width: 20%; height: 40px; line-height: 40px; position:fixed; bottom:0; cursor: pointer; } .st-container > input{ opacity:0; z-index: 1000; } .st-container > a{ z-index: 10; font-weight: 700; font-size: 16px; background-color: #e23a6e; color: #fff; text-align: center; text-shadow:1px 1px 1px rgba(151,24,64,0.2); -webkit-transition:all 0.5s; -moz-transition:all 0.5s; transition:all 0.5s; } #st-control-1,#st-control-1 + a{ left:0%; } #st-control-2,#st-control-2 + a{ left:20%; } #st-control-3,#st-control-3 + a{ left:40%; } #st-control-4,#st-control-4 + a{ left:60%; } #st-control-5,#st-control-5 + a{ left:80%; } .st-container input:checked + a,.st-container input:checked:hover + a{ background-color: #821134; } .st-container input:checked + a:after{ content: ''; width: 0; height: 0; overflow: hidden; border:20px solid transparent; border-bottom-color:#821134; position: absolute; bottom:100%; left:50%; /*transform:translateX(-50%);*/ margin-left: -20px; } .st-container input:hover + a{ background-color: #ad244f; } /*内容区域*/ .st-scroll, .st-scroll .st-panel{ height: 100%; width: 100%; position: relative; } .st-scroll{ left:0; top:0; -webkit-transform:translate3d(0,0,0); -moz-transform:translate3d(0,0,0); transform:translate3d(0,0,0); -webkit-backface-visibility:hidden; -webkit-transition:all 0.6s ease-in-out; -moz-transition:all 0.6s ease-in-out; transition:all 0.6s ease-in-out; } .st-panel{ background-color: #fff; overflow: hidden; } .st-color{ background-color: #fa96b5; color: #fff; } #st-control-1:checked ~ .st-scroll{ -webkit-transform:translateY(0%); -moz-transform:translateY(0%); transform:translateY(0%); } #st-control-2:checked ~ .st-scroll{ -webkit-transform:translateY(-100%); -moz-transform:translateY(-100%); transform:translateY(-100%); } #st-control-3:checked ~ .st-scroll{ -webkit-transform:translateY(-200%); -moz-transform:translateY(-200%); transform:translateY(-200%); } #st-control-4:checked ~ .st-scroll{ -webkit-transform:translateY(-300%); -moz-transform:translateY(-300%); transform:translateY(-300%); } #st-control-5:checked ~ .st-scroll{ -webkit-transform:translateY(-400%); -moz-transform:translateY(-400%); transform:translateY(-400%); } .st-desc{ width: 200px; height: 200px; background-color: #fa96b5; position: absolute; left:50%; top:0; margin-left: -100px; -webkit-transform:translateY(-50%) rotate(45deg); -moz-transform:translateY(-50%) rotate(45deg); transform:translateY(-50%) rotate(45deg); } .st-color .st-desc{ background-color: #fff; } [data-icon]:after{ content: attr(data-icon); width: 200px; height: 200px; color: #fff; font-size: 90px; text-align: center; line-height: 200px; position: absolute; left: 50%; top:50%; margin: -100px 0 0 -100px; -webkit-transform:rotate(-45deg) translateY(25%); -moz-transform:rotate(-45deg) translateY(25%); transform:rotate(-45deg) translateY(25%); font-family:"Raphaelicons"; text-shadow:1px 1px 1px rgba(151,24,64,0.2); } .st-color [data-icon]:after{ color: #fa96b5; text-shadow:1px 1px 1px rgba(0,0,0,0.1); } .st-panel h2{ color: #e23a6e; font-size: 54px; line-height: 50px; text-align: center; font-weight: 900; width: 80%; position: absolute; left:10%; top:150px; text-shadow: 1px 1px 1px rgba(151,24,64,0.2); -webkit-backface-visibility:hidden; } .st-color h2{ color: #fff; text-shadow:1px 1px 1px rgba(0,0,0,0.1); } #st-control-1:checked ~ .st-scroll #st-panel-1 h2, #st-control-2:checked ~ .st-scroll #st-panel-2 h2, #st-control-3:checked ~ .st-scroll #st-panel-3 h2, #st-control-4:checked ~ .st-scroll #st-panel-4 h2, #st-control-5:checked ~ .st-scroll #st-panel-5 h2{ -webkit-animation:moveDown 0.6s ease-in-out 0.2s backwards; -moz-animation:moveDown 0.6s ease-in-out 0.2s backwards; -o-animation:moveDown 0.6s ease-in-out 0.2s backwards; -ms-animation:moveDown 0.6s ease-in-out 0.2s backwards; animation:moveDown 0.6s ease-in-out 0.2s backwards; } @-webkit-keyframes moveDown{ 0%{ -webkit-transform:translateY(-40px); opacity:0; } 100%{ -webkit-transform:translateY(0px); opacity:1; } } @-moz-keyframes moveDown{ 0%{ -moz-transform:translateY(-40px); opacity:0; } 100%{ -moz-transform:translateY(0px); opacity:1; } } @-o-keyframes moveDown{ 0%{ -o-transform:translateY(-40px); opacity:0; } 100%{ -o-transform:translateY(0px); opacity:1; } } @-ms-keyframes moveDown{ 0%{ -ms-transform:translateY(-40px); opacity:0; } 100%{ -ms-transform:translateY(0px); opacity:1; } } @keyframes moveDown{ 0%{ transform:translateY(-40px); opacity:0; } 100%{ transform:translateY(0px); opacity:1; } } .st-panel p{ font-size: 25px; color: #8b8b8b; line-height: 1.8; text-align: left; text-indent: 2em; font-weight: 700; width: 70%; position: absolute; left:15%; top:280px; text-shadow: 1px 1px 1px rgba(151,24,64,0.2); -webkit-backface-visibility:hidden; } .st-color p{ color:rgba(255,255,255,0.8); text-shadow:1px 1px 1px rgba(0,0,0,0.1); } #st-control-1:checked ~ .st-scroll #st-panel-1 p, #st-control-2:checked ~ .st-scroll #st-panel-2 p, #st-control-3:checked ~ .st-scroll #st-panel-3 p, #st-control-4:checked ~ .st-scroll #st-panel-4 p, #st-control-5:checked ~ .st-scroll #st-panel-5 p{ -webkit-animation:moveUp 0.6s ease-in-out 0.2s backwards; -moz-animation:moveUp 0.6s ease-in-out 0.2s backwards; -o-animation:moveUp 0.6s ease-in-out 0.2s backwards; -ms-animation:moveUp 0.6s ease-in-out 0.2s backwards; animation:moveUp 0.6s ease-in-out 0.2s backwards; } @-webkit-keyframes moveUp{ 0%{ -webkit-transform:translateY(40px); opacity:0; } 100%{ -webkit-transform:translateY(0px); opacity:1; } } @-moz-keyframes moveUp{ 0%{ -moz-transform:translateY(40px); opacity:0; } 100%{ -moz-transform:translateY(0px); opacity:1; } } @-o-keyframes moveUp{ 0%{ -o-transform:translateY(40px); opacity:0; } 100%{ -o-transform:translateY(0px); opacity:1; } } @-ms-keyframes moveUp{ 0%{ -ms-transform:translateY(40px); opacity:0; } 100%{ -ms-transform:translateY(0px); opacity:1; } } @keyframes moveUp{ 0%{ transform:translateY(40px); opacity:0; } 100%{ transform:translateY(0px); opacity:1; } } @media screen and (max-width:520px){ .st-panel h2{ font-size: 42px; } .st-panel p{ font-size: 18px; width: 90%; left:5%; top:240px; } .st-container > a{ font-size: 13px; } .st-desc{ width: 160px; height:160px; margin-left: -80px; } [data-icon]:after{ font-size: 75px; -webkit-transform:rotate(-45deg) translateY(20%); -moz-transform:rotate(-45deg) translateY(20%); transform:rotate(-45deg) translateY(20%); } } @media screen and (max-width:360px){ .st-panel h2{ font-size: 42px; } .st-panel p{ font-size: 18px; width: 90%; left:5%; top:240px; } .st-container > a{ font-size: 10px; } .st-desc{ width: 120px; height:120px; margin-left: -60px; } [data-icon]:after{ font-size: 60px; -webkit-transform:rotate(-45deg) translateY(15%); -moz-transform:rotate(-45deg) translateY(15%); transform:rotate(-45deg) translateY(15%); } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值