CSS3 2D Transforms
来源:互联网 发布:deepin linux 15.4.1 编辑:程序博客网 时间:2024/05/18 03:10
CSS3 Transforms
With CSS3 transform, we can move, scale, turn, spin, and stretchelements.
How Does it Work?
A transform is an effect that lets an element change shape, sizeand position.
You can transform your elements using 2D or 3D transformation.
Browser Support
Internet Explorer 9 requires the prefix -ms-.
Firefox requires the prefix -moz-.
Chrome and Safari requires the prefix -webkit-.
Opera requires the prefix -o-.
2D Transforms
In this chapter you will learn about the 2d transform methods:
- translate()
- rotate()
- scale()
- skew()
- matrix()
You will learn about 3D transforms in the next chapter.
Example
{
transform: rotate(30deg);
-ms-transform: rotate(30deg);
-webkit-transform: rotate(30deg);
-o-transform: rotate(30deg);
-moz-transform: rotate(30deg);
}
Try it yourself »
The translate() Method
With the translate() method, the element moves from its currentposition, depending on the parameters given for the left (X-axis)and the top (Y-axis) position:
Example
{
transform: translate(50px,100px);
-ms-transform: translate(50px,100px);
-webkit-transform: translate(50px,100px);
-o-transform: translate(50px,100px);
-moz-transform: translate(50px,100px);
}
Try it yourself »
The value translate(50px,100px) moves the element 50 pixels fromthe left, and 100 pixels from the top.
The rotate() Method
With the rotate() method, the element rotates clockwise at a givendegree. Negative values are allowed and rotates the elementcounter-clockwise.
Example
{
transform: rotate(30deg);
-ms-transform: rotate(30deg);
-webkit-transform: rotate(30deg);
-o-transform: rotate(30deg);
-moz-transform: rotate(30deg);
}
Try it yourself »
The value rotate(30deg) rotates the element clockwise 30degrees.
The scale() Method
With the scale() method, the element increases or decreases thesize, depending on the parameters given for the width (X-axis) andthe height (Y-axis):
Example
{
transform: scale(2,4);
-ms-transform: scale(2,4);
-webkit-transform: scale(2,4);
-o-transform: scale(2,4);
-moz-transform: scale(2,4);
}
Try it yourself »
The value scale(2,4) transforms the width to be twice its originalsize, and the height 4 times its original size.
The skew() Method
With the skew() method, the element turns in a given angle,depending on the parameters given for the horizontal (X-axis) andthe vertical (Y-axis) lines:
Example
{
transform: skew(30deg,20deg);
-ms-transform: skew(30deg,20deg);
-webkit-transform: skew(30deg,20deg);
-o-transform: skew(30deg,20deg);
-moz-transform: skew(30deg,20deg);
}
Try it yourself »
The value skew(30deg,20deg) turns the element 30 degrees around theX-axis, and 20 degrees around the Y-axis.
The matrix() Method
The matrix() method combines all of the 2D transform methods intoone.
The matrix method take six parameters, containing mathematicfunctions, which allows you to: rotate, scale, move (translate),and skew elements.
Example
How to rotate a div element 30 degrees, usingthe matrix method:
{
transform:matrix(0.866,0.5,-0.5,0.866,0,0);
-ms-transform:matrix(0.866,0.5,-0.5,0.866,0,0);
-moz-transform:matrix(0.866,0.5,-0.5,0.866,0,0);
-webkit-transform:matrix(0.866,0.5,-0.5,0.866,0,0);
-o-transform:matrix(0.866,0.5,-0.5,0.866,0,0);
}
Try it yourself »
New Transform Properties
The following table lists all the transform properties:
2D Transform Methods
- CSS3 2D Transforms
- CSS3 3D Transforms
- css3 的艰难
- css3 属性 transition
- CSS3 3D transforms系列-3D旋转木马
- ESLPodcast 12 - D…
- [转]Css3: animation
- CSS3 Animations
- CSS3-阴影 效果
- ❤️初识cocoas 2D -x
- CSS3 3D Transforms各浏览器支持情况
- HDOJ 2503 a/b + c/d
- 内部赛 3 D Deli Deli
- CSS3 box-shadow Property
- CSS3 background-size Property
- CSS3 text-shadow Property
- CSS3 word-wrap Property
- 【css3】transform 下 p…
- CSS3 background-size Property
- 链表和队列复习
- CSS3 text-shadow Property
- CSS3 word-wrap Property
- OpenCV IplImage和GDI+ Bitmap的相互转换
- CSS3 2D Transforms
- CSS3 3D Transforms
- CSS3 Animations
- ThinkPHP3.1快速入门(13)自动完…
- event keycode大全
- ThinkPHP中结果唯一性的作法
- javascript函数设置默认值
- JQuery获取浏览器窗口的可视区域高…
- Sphinx 在 windows 下安装使用