What does the Transform-origin property in CSS do? The role of the Transform-origin attribute

Source: Internet
Author: User
This article introduces you to what is the Transform-origin attribute in CSS? Transform-origin properties of the role, there is a certain reference value, the need for friends can refer to, I hope to help you

A recent fireworks animation, is the fireworks scattered animation, in the implementation of the animation process, mainly in the fireworks spinning process stuck, and later found that the main transform-origin attribute understanding is not deep, specifically to find an example to practice, deepened the understanding of the attributes.

transform-originRole

This property is used to change the origin of the element's deformation and is generally used to match the rotation to the most. The receive parameters can be one, two, three. When two values represent the value of the left side of the distance box model, for example transform-origin: 50px 50px; , the center of rotation for the container changes to the upper left corner of the box model, and the x and Y axes are rotated at the origin point of 50px.

Drawing of the Clock hour

The middle bar is set for us at the beginning, and the back is rotated based on this.

  <p class= "Clock" >    <p class= "Hour" ></p>    <p class= "Hour" ></p>    <p class= "Hour" ></p>    <p class= "Hour" ></p>    <p class= "Hour" ></p>  </p>

As can be seen from the following CSS code, we set the rotation center for the first vertical bar (3,105) px for the origin of rotation, the distance is the distance box model to the left of the value, understand this, you can write the other hours, and then rotate each to get the hour hand. Because we do not understand where the value is calculated relative to which position, thus stepping on a lot of pits.

Css

. hour {  position:absolute;  left:105px;  width:6px;  height:50px;  Background-color: #000;  border-radius:6px;  -WEBKIT-TRANSFORM-ORIGIN:3PX 105px;           Transform-origin:3px 105px;}. Hour:nth-child (2) {  transform:rotate (45deg);}. Hour:nth-child (3) {  transform:rotate (90deg);}. Hour:nth-child (4) {  transform:rotate ( -45deg);}. Hour:nth-child (5) {  transform:rotate ( -90deg);}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.