transform 屬性之 transform-origin

來源:互聯網
上載者:User
定義

transform-origin 屬性用來設定 transform 變換的基點位置。預設情況下,基點位置為元素的中心點。 文法

transform-origin: x-axis y-axis z-axis

名稱 描述
x-axis 位置(left、center、right)/ 百分數 / 數值 x 軸基點座標
y-axis 位置(top、center、bottom)/ 百分數 / 數值 y 軸基點座標
z-axis 數值 Z 軸基點座標

注意:當用數值設定基點位置時,必須帶單位位置

使用位置設定變換基點代碼如下:

.transform-origin-position {    transform: rotate(45deg);    transform-origin: left top;}

不同位置資訊效果如下(標紅圈處為變換基點): left-top

left-center

left-bottom

center-top

right-top

百分數

使用百分數設定變換基點代碼如下:

.transform-origin-percent {    animation: 9s rotate infinite;    transform-origin: 25% 25%;}

效果如下:

如上圖,紅圈處為元素變換基點。即代碼中設定的 x 軸和 y 軸值25%。 數值

使用數值設定變換基點代碼如下:

.transform-origin-number {    transform: rotate(45deg);    transform-origin: 100px 0;}

注意此處數值後面必須帶單位。

效果如下:

圖中紅圈處位置即為 x 軸 100px 的位置。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.