溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

css3中translate和transition怎么用

發(fā)布時間:2021-03-20 10:06:59 來源:億速云 閱讀:151 作者:小新 欄目:web開發(fā)

這篇文章給大家分享的是有關css3中translate和transition怎么用的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

示例:

<!DOCTYPE html>
<html>
<head>
  <title>translate和transition</title>
</head>
<body>
<style type="text/css">
  div {
    width: 100px;
    height: 75px;
    background-color: red;
    border: 1px solid black;
  }

  div#translate {
    transition: all 2s;
    -ms-transition: all 2s;
    -webkit-transition: all 2s;
  }

  div#translate:hover{
    transform: translate(50px, 100px);
    -ms-transform: translate(50px, 100px);
    -webkit-transform: translate(50px, 100px);
  }
</style>
<div>Hello, This is a Div element</div>
<div id='translate'>Hello, This is another Div element</div>
</body>
</html>

演示demo請點(這里)[/css3/translate.html]

translate(a, b):用官方的話說叫做2D轉移,其實就是平面上的x軸和y軸移動,搞那么多名詞就是因為我們學識太低,不想讓我們容易了解
a - 在橫向(左右方向)也就是x軸移動a單位距離,比如是10px,那么就移動10px,正值向右移動,負值向左移動 b - 在縱向(上下方向)也就是y軸移動b單位距離,比如是50px,那么就移動10px,正值向下移動,負值向上移動

起點在左上角哈,但是如果元素位置開始就設置了非原點的話就另說了,就是在元素基礎上做計算

原點(0,0)-------
|
|
|

transition 動畫過渡

transition: property duration timing-function delay

property - css屬性

duration - 動畫執(zhí)行時長 如果為0 動畫不執(zhí)行

timing-function 動畫執(zhí)行方式 默認ease

delay - 動畫延遲執(zhí)行時間 默認0

感謝各位的閱讀!關于“css3中translate和transition怎么用”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI