当前位置:网站首页>Detailed explanation of transform origin attribute
Detailed explanation of transform origin attribute
2022-07-07 07:14:00 【Luqi zz】
transform-origin Base point for animating ( Center point ) , Applicable to all block level elements and some inline elements .
Must cooperate transform Use By default , The action reference point of the element is the center of the element box
You can set the value of nine positions : horizontal direction : left center right
0 50% 100%
vertical direction : top center bottom
The default value is :50% 50% , be relative to center center
Two ways of writing ,
eg:
transform-origin: left;
transform-origin:0;
grammar :
transform-origin: x-axis y-axis z-axis;

Attribute value details
<div class="outer">
<div class="inner"></div>
<div class="inner"></div>
</div>1. The default value is , Rotate at its origin 45deg
.outer {
width: 100px;
height: 100px;
background-color: #6a5acd8c;
margin: 200px;
position: relative;
}
/* (1) Default rotation , Red is the base point The default value is transform-origin: 50% 50% 0;*/
.inner {
transform: rotate(45deg);
/* transform-origin: 50% 50% 0; */
width: 100%;
height: 100%;
background-color: #6a5acdeb;
}
.outer .inner:nth-child(2){
width: 5px;
height: 5px;
background-color: red;
transform: none;
position: absolute;
top: 50px;
left: 50px;
}
2. Rotate at the top 180deg
.outer {
width: 100px;
height: 100px;
background-color: #6a5acd8c;
margin: 200px;
position: relative;
}
/* (2) Rotate at the top 180deg */
.inner {
transform: rotate(180deg);
transform-origin: 50% 0;
width: 100%;
height: 100%;
background-color: #6a5acdeb;
}
.inner:nth-child(2) {
width: 5px;
height: 5px;
background-color: red;
transform: none;
position: absolute;
top: -2.5px;
left: 50px;
} 
3. Rotate on the right 150deg
/* Rotate on the right 150deg Red is the base point */
.inner {
transform: rotate(150deg);
transform-origin: 100% 50%;
width: 100%;
height: 100%;
background-color: #6a5acdeb;
}
.inner:nth-child(2) {
width: 5px;
height: 5px;
background-color: red;
transform: none;
position: absolute;
top: 47.5px;
left: 97.5px;
}
4. Rotate in the upper left corner 20deg Red is the base point
.inner {
transform: rotate(-20deg);
transform-origin: 0 0;
width: 100%;
height: 100%;
background-color: #6a5acdeb;
}
.inner:nth-child(2) {
width: 5px;
height: 5px;
background-color: red;
transform: none;
position: absolute;
top: -2.5px;
left: -2.5px;
}
From the above example, we can see , The offset position represented by the attribute value , Knowing the offset position represented by each attribute value can flexibly make the element rotate according to a certain benchmark .
边栏推荐
- 2018 Jiangsu Vocational College skills competition vocational group "information security management and evaluation" competition assignment
- How can clothing stores make profits?
- Readonly read only
- Bus消息总线
- Initial experience of addresssanitizer Technology
- 组件的通信
- Unity C function notes
- How does an enterprise manage data? Share the experience summary of four aspects of data governance
- After the promotion, sales volume and flow are both. Is it really easy to relax?
- Graduation design game mall
猜你喜欢

$parent(获取父组件) 和 $root(获取根组件)

Paranoid unqualified company

Composition API 前提

How can gyms improve their competitiveness?

Maze games based on JS

Non empty verification of collection in SQL

弹性布局(一)

Introduction to abnova's in vitro mRNA transcription workflow and capping method

Basic introduction of JWT

Lm11 reconstruction of K-line and construction of timing trading strategy
随机推荐
How can clothing stores make profits?
詳解機器翻譯任務中的BLEU
详解机器翻译任务中的BLEU
ViewModelProvider. Of obsolete solution
Reflection (II)
组件的嵌套和拆分
Sword finger offer high quality code
Precise space-time travel flow regulation system - ultra-high precision positioning system based on UWB
Under what circumstances should we consider sub database and sub table
Freeswitch dials extension number source code tracking
This article introduces you to the characteristics, purposes and basic function examples of static routing
. Net 5 fluentftp connection FTP failure problem: this operation is only allowed using a successfully authenticated context
Big coffee gathering | nextarch foundation cloud development meetup is coming
Nesting and splitting of components
Take you to brush (niuke.com) C language hundred questions (the first day)
Test of transform parameters of impdp
LC 面试题 02.07. 链表相交 & LC142. 环形链表II
MOS tube parameters μ A method of Cox
JS decorator @decorator learning notes
虚拟机的作用