当前位置:网站首页>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 .
边栏推荐
- How can brand e-commerce grow against the trend? See the future here!
- $refs: get the element object or sub component instance in the component:
- Esxi attaching mobile (Mechanical) hard disk detailed tutorial
- Please answer the questions about database data transfer
- Apache AB stress test
- Abnova circulating tumor DNA whole blood isolation, genomic DNA extraction and analysis
- Basic process of network transmission using tcp/ip four layer model
- 工具类:对象转map 驼峰转下划线 下划线转驼峰
- LC 面试题 02.07. 链表相交 & LC142. 环形链表II
- Algorithm --- bit count (kotlin)
猜你喜欢

How does an enterprise manage data? Share the experience summary of four aspects of data governance

RuntimeError: CUDA error: CUBLAS_ STATUS_ ALLOC_ Failed when calling `cublascreate (handle) `problem solving

Complete process of MySQL SQL

Asynchronous components and suspend (in real development)

CompletableFuture使用详解

关于数据库数据转移的问题,求各位解答下

2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书

Pass child component to parent component

The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby

Graduation design game mall
随机推荐
大咖云集|NextArch基金会云开发Meetup来啦
[Luogu p1971] rabbit and egg game (bipartite game)
Bus消息总线
Tumor immunotherapy research prosci Lag3 antibody solution
2018 Jiangsu Vocational College skills competition vocational group "information security management and evaluation" competition assignment
After the promotion, sales volume and flow are both. Is it really easy to relax?
Config distributed configuration center
关于二进制无法精确表示小数
PostgreSQL source code (59) analysis of transaction ID allocation and overflow judgment methods
Please tell me how to monitor multiple schemas and tables by listening to PgSQL
【JDBC以及内部类的讲解】
Maze games based on JS
$refs: get the element object or sub component instance in the component:
Nesting and splitting of components
Can 7-day zero foundation prove HCIA? Huawei certification system learning path sharing
Common function detect_ image/predict
SolidWorks GB Library (steel profile library, including aluminum profile, aluminum tube and other structures) installation and use tutorial (generating aluminum profile as an example)
MySQL view bin log and recover data
Leetcode t1165: log analysis
Torefs API and toref API