Home >Web Front-end >HTML Tutorial >Common CSS styles (3)

Common CSS styles (3)

WBOY
WBOYOriginal
2016-08-15 16:49:511245browse

1. 2D transformation

 1. transform Set or retrieve the transformation of the object

Value:

  none: Specify a 2D transformation in the form of a six-value (a, b, c, d, e, f) transformation matrix, which is equivalent to directly applying a [a, b, c, d, e, f] Transformation matrix

translate([, ]). The first parameter corresponds to the X-axis, and the second parameter corresponds to the Y-axis. If the second parameter is not provided, the default value is 0.              

TranslateX(): Specifies the translation of the X-axis (horizontal direction) of the object

 translateY(): Specify the translation of the Y-axis (vertical direction) of the object

rotate(): Specify the 2D rotation of the object. The first parameter corresponds to the X-axis, and the second parameter corresponds to the Y-axis. If the second parameter is not provided, the value of the first parameter will be taken by default

scaleX(): Specifies the (horizontal) scaling of the X-axis of the object

 scaleY(): Specifies the (vertical) scaling of the Y-axis of the object

skew( [, ]): Specify object skew transformation (oblique distortion). The first parameter corresponds to the X-axis, and the second parameter corresponds to the Y-axis. If the second parameter is not provided, the default value is 0 skewX(): Specifies the (horizontal) distortion of the object's X-axis

 skewY(): Specifies the (vertical) distortion of the Y-axis of the object

 Note: Different browsers require the following prefixes.

Kernel type Writing
Webkit(Chrome/Safari) -webkit-transform
Gecko(Firefox) -moz-transform
Presto(Opera) -o-transform
Trident(IE) -ms-transform
W3C transform

Example:

CSS code:

<span style="font-size: 14px;"><span style="color: #800000;">      #transform1
        </span>{<span style="color: #ff0000;">
            margin</span>:<span style="color: #0000ff;"> 0 auto</span>;<span style="color: #ff0000;">
            width</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;">
            height</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> mediumvioletred</span>;<span style="color: #ff0000;">
            -webkit-transform</span>:<span style="color: #0000ff;"> rotate(15deg)</span>;
         }</span>

HTML code:

<span style="font-size: 15px;"><span style="color: #0000ff;"><</span><span style="color: #800000;">div </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="transform1"</span><span style="color: #0000ff;">></span>旋转了15度<span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span></span>

2. transform-origin Set or retrieve the object to be transformed at a certain origin.

Value:

 : Specify coordinate values ​​in percentage. Can be negative.

: Specify the coordinate value with the length value. Can be negative.

left: Specify the abscissa of the origin as leftcenter①: Specify the abscissa of the origin as

centerright: Specify the abscissa of the origin as

Righttop: Specify the ordinate of the origin as

topcenter②: Specify the ordinate of the origin as

centerbottom: Specify the vertical coordinate of the origin as bottom 

How to write it in different browsers:

Kernel type Writing
Webkit(Chrome/Safari) -webkit-transform-origin
Gecko(Firefox) -moz-transform-origin
Presto(Opera) -o-transform-origin
Trident(IE) -ms-transform-origin
W3C transform-origin

  

 

 

 

 

  例子:

  CSS代码:

<span style="font-size: 15px;"><span style="color: #800000;">        #transform1
        </span>{<span style="color: #ff0000;">
            margin</span>:<span style="color: #0000ff;"> 0 auto</span>;<span style="color: #ff0000;">
            width</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;">
            height</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> mediumvioletred</span>;<span style="color: #ff0000;">
            -webkit-transform</span>:<span style="color: #0000ff;"> rotate(15deg)</span>;/*旋转15度*/<span style="color: #ff0000;">
            -webkit-transform-origin</span>:<span style="color: #0000ff;"> left top</span>; /*以左上角为原点旋转*/
        } </span>       

  HTML代码:

<span style="font-size: 15px;"><span style="color: #0000ff;"><</span><span style="color: #800000;">div </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="transform1"</span><span style="color: #0000ff;">></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span></span>

  

   二、过渡样式

    1、transition-property  检索或设置对象中的参与过渡的属性。

    取值:

    all:所有可以进行过渡的css属性
   none:不指定过渡的css属性
 有过渡效果的属性:
  
        例子:
    CSS代码: 
<span style="font-size: 15px;"><span style="color: #800000;">         #transform1
        </span>{<span style="color: #ff0000;">
            margin</span>:<span style="color: #0000ff;"> 0 auto</span>;<span style="color: #ff0000;">
            width</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;">
            height</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> red</span>;<span style="color: #ff0000;">
            transition-property</span>:<span style="color: #0000ff;"> background-color</span>;
            
        }<span style="color: #800000;">
        #transform1:hover
        </span>{<span style="color: #ff0000;">
            transition-duration</span>:<span style="color: #0000ff;">.5s</span>;<span style="color: #ff0000;">
            transition-timing-function</span>:<span style="color: #0000ff;">ease-in</span>;<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> yellow</span>;
        }
                </span>
    HTML代码:
<span style="font-size: 15px;"><span style="color: #0000ff;"><</span><span style="color: #800000;">div </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="transform1"</span><span style="color: #0000ff;">></span>请将鼠标放在上面<span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span></span>
请将鼠标放在上面
      2、transition-duration   检索或设置对象过渡的持续时间
     transition-duration:time
     例子可参见上个例子。
    3、transition-timing-function  检索或设置对象中过渡的动画类型。
   取值:
   linear:线性过渡。等同于贝塞尔曲线(0.0, 0.0, 1.0, 1.0)
          ease:平滑过渡。等同于贝塞尔曲线(0.25, 0.1, 0.25, 1.0)
          ease-in:由慢到快。等同于贝塞尔曲线(0.42, 0, 1.0, 1.0)
          ease-out:由快到慢。等同于贝塞尔曲线(0, 0, 0.58, 1.0)
          ease-in-out:由慢到快再到慢。等同于贝塞尔曲线(0.42, 0, 0.58, 1.0)cubic-bezier(, , , ):特定的贝塞尔曲线类型,4个数值需           在[0, 1]区间内。
   例子可参见上个例子。
 
   4、transition-delay   设置对象延迟过渡的时间。
 
   CSS代码:
<span style="font-size: 15px;"><span style="color: #800000;">        #delay1
        </span>{<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> antiquewhite</span>;<span style="color: #ff0000;">
            width</span>:<span style="color: #0000ff;">100px</span>;<span style="color: #ff0000;">
            height</span>:<span style="color: #0000ff;">100px</span>;                
        }<span style="color: #800000;">
        #delay1:hover
        </span>{<span style="color: #ff0000;">
            transition-delay</span>:<span style="color: #0000ff;">1s</span>;<span style="color: #ff0000;">
            transition-timing-function</span>:<span style="color: #0000ff;">ease-in</span>;<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> black</span>;
        }<span style="color: #800000;">
        #delay2
        </span>{<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> antiquewhite</span>;<span style="color: #ff0000;">
            width</span>:<span style="color: #0000ff;">100px</span>;<span style="color: #ff0000;">
            height</span>:<span style="color: #0000ff;">100px</span>;                
        }<span style="color: #800000;">
        #delay2:hover
        </span>{<span style="color: #ff0000;">
            transition-delay</span>:<span style="color: #0000ff;">4s</span>;<span style="color: #ff0000;">
            transition-timing-function</span>:<span style="color: #0000ff;">ease-in</span>;<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> blue</span>;
        }     </span>       
   HTML代码; 
<span style="font-size: 15px;"><span style="color: #0000ff;"><</span><span style="color: #800000;">div </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="delay1"</span><span style="color: #0000ff;">><span style="color: #000000;">延迟</span></span>1s后开始过渡<span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #0000ff;"><</span><span style="color: #800000;">div </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="delay2"</span><span style="color: #0000ff;">></span>延迟4s后开始过渡<span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span></span>
延迟1s后开始过渡
延迟4s后开始过渡
 
      ***一般情况下可以将变形与过渡结合使用制作出一些特别的效果。
        例:
  CSS代码:
  
<span style="font-size: 15px;"><span style="color: #800000;">        #all
        </span>{<span style="color: #ff0000;">
            width</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;">
            height</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> red</span>;            
        }<span style="color: #800000;">
        #all:hover
        </span>{<span style="color: #ff0000;">
            background-color</span>:<span style="color: #0000ff;"> yellow</span>;<span style="color: #ff0000;">
            transition-delay</span>:<span style="color: #0000ff;"> .5s</span>;<span style="color: #ff0000;">
            transition-timing-function</span>:<span style="color: #0000ff;"> ease-in</span>;<span style="color: #ff0000;">
            transform</span>:<span style="color: #0000ff;"> scale(1.5,1.5)</span>;<span style="color: #ff0000;">
            transition-duration</span>:<span style="color: #0000ff;"> 1s</span>;
        }   </span>                     
  HTML代码:
<span style="font-size: 15px;"><span style="color: #0000ff;">  <</span><span style="color: #800000;">div </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="all"</span><span style="color: #0000ff;">></span>请把鼠标放在上面查看效果<span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span></span>
请把鼠标放在上面查看效果
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Example of *LotteryNext article:Example of *Lottery