Can you use CSS to mirror/flip text?

后端 未结 14 2249
旧时难觅i
旧时难觅i 2020-11-28 01:27

Is it possible to use CSS/CSS3 to mirror text?

Specifically, I have this scissors char “✂” () that I\'d like to display pointing left a

相关标签:
14条回答
  • 2020-11-28 02:04

    Real mirror:

    .mirror{
        display: inline-block; 
        font-size: 30px;
    
        -webkit-transform: matrix(-1, 0, 0, 1, 0, 0);
        -moz-transform: matrix(-1, 0, 0, 1, 0, 0);
        -o-transform: matrix(-1, 0, 0, 1, 0, 0);
        transform: matrix(-1, 0, 0, 1, 0, 0);
    }
    <span class='mirror'>Mirror Text<span>

    0 讨论(0)
  • 2020-11-28 02:04

    I cobbled together this solution by scouring the Internet including

    • Stack Overflow answers,
    • MSDN articles,
    • http://css-tricks.com/almanac/properties/t/transform/,
    • http://caniuse.com/#search=transform,
    • http://browserhacks.com/, and
    • http://www.useragentman.com/IETransformsTranslator/.

    This solution seems to work in all browsers including IE6+, using scale(-1,1) (a proper mirror) and appropriate filter/-ms-filter properties when necessary (IE6-8):

    /* Cross-browser mirroring of content. Note that CSS pre-processors
      like Less cough on the media hack. 
    
      Microsoft recommends using BasicImage as a more efficent/faster form of
      mirroring, instead of FlipH or some kind of Matrix scaling/transform.
      @see http://msdn.microsoft.com/en-us/library/ms532972%28v=vs.85%29.aspx
      @see http://msdn.microsoft.com/en-us/library/ms532992%28v=vs.85%29.aspx
    */
    
    /* IE8 only via hack: necessary because IE9+ will also interpret -ms-filter,
      and mirroring something that's already mirrored results in no net change! */
    @media \0screen {
      .mirror {
        -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(mirror=1)";
      }
    }
    .mirror {
      /* IE6 and 7 via hack */
      *filter: progid:DXImageTransform.Microsoft.BasicImage(mirror=1);
      /* Standards browsers, including IE9+ */
      -moz-transform: scale(-1,1);
      -ms-transform: scale(-1,1);
      -o-transform: scale(-1,1); /* Op 11.5 only */
      -webkit-transform: scale(-1,1);
      transform: scale(-1,1);
    }
    
    0 讨论(0)
提交回复
热议问题