How to apply multiple transforms in CSS?

前端 未结 7 1430
死守一世寂寞
死守一世寂寞 2020-11-22 06:09

Using CSS, how can I apply more than one transform?

Example: In the following, only the translation is applied, not the rotation.

li:nth         


        
7条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 06:56

    Some time in the future, we can write it like this:

    li:nth-child(2) {
        rotate: 15deg;
        translate:-20px 0px;        
    }
    

    This will become especially useful when applying individual classes on an element:

    .teaser{rotate:10deg;} .important{scale:1.5 1.5;}

    This syntax is defined in the in-progress CSS Transforms Level 2 specification, but can't find anything about current browser support other then chrome canary. Hope some day i'll come back and update browser support here ;)

    Found the info in this article which you might want to check out regarding workarounds for current browsers.

提交回复
热议问题