CSS3 transform rotate causing 1px shift in Chrome

前端 未结 3 878
暗喜
暗喜 2020-12-02 20:09

I\'m having an issue in chrome with a css3 transform rotate transition. The transition is working fine but just after it finishes the element shifts by a pixel. The other st

3条回答
  •  星月不相逢
    2020-12-02 20:30

    there is something unusual in the relation between the body dimension and the structure of the transform. I don't in fact is because the fiddle iframe that contains the preview of the code.

    Anyway, I will suggest this approach instead:

    body{
      width:100%;
      float:left;
    }
    
    .wrap {
      margin: 50px 45%;
      width: 5%;
      float: left;
    }
    .block {
      width:30px;
      height:30px;
      background:black;
    }
    .target,.block {
      -webkit-transition: all 0.4s ease;
      -moz-transition: all 0.4s ease;
    -o-transition: all 0.4s ease;
    transition: all 0.4s ease;
    }
    .target:hover,.block:hover {
    -webkit-transform: rotate(90deg); 
        -moz-transform: rotate(90deg); 
        -o-transform: rotate(90deg);
        -ms-transform: rotate(90deg);  
    }
    

    Here is the updated fiddle

提交回复
热议问题