search

Home  >  Q&A  >  body text

iconfont font icon rotation - Stack Overflow

<i class="iconfont rotate"></i>
.rotate{transform: rotate(90deg)}

The icon is not rotated on the page. You are using the Chrome browser. Can you tell me why?
Is it true that Alibaba’s vector icons do not support rotation

<i class="icon iconfont icon-leftnav-ss" style="transform: rotate(90deg);"></i>

Thank you, there is still no change in the page

学习ing学习ing2706 days ago1396

reply all(4)I'll reply

  • 迷茫

    迷茫2017-06-26 10:54:06

    First of all, you should download the source code of Alibaba iconfont. There is demo_fontclass.html in the source code package, which contains the class name and usage instructions of the icon characters you need.
    Here are some brief instructions:

    After introducing the iconfont.css in the downloaded package, you need to enter class="iconfont icon-xxx" to use the iconfont font. For the specific icon-xxx, please refer to the demo_fontclass.html file, which is based on your packaging Depends.

    Secondly, if you just need to rotate the icon, please change .rotate to .rotate:before, because iconfont is an icon added to the element through the content CSS attribute of the :beforepseudo element.

    Update

    Get the code first

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8">
        <link rel="stylesheet" type="text/css" href="iconfont.css">
        <style type="text/css">
        .rotate:before {
            font-size: 40px;
            display: inline-block;
            transform: rotate(90deg);
        }
        </style>
    </head>
    <body>
        <i class="iconfont icon-48xiaoshifahuo rotate"></i>
        <i class="iconfont icon-24xiaoshifahuo rotate"></i>
    </body>
    </html>
    1. First of all, the implementation of the icon is controlled by :beforepseudo-element

    2. :before pseudo-element is an inline element by default (i.e. display: inline)

    3. The rotation of inline elements is invalid, so you need to add display: inline-block to the .rotate:before pseudo-element to make it an inline block element.

    The effect of the above HTML code is as follows:

    reply
    0
  • PHP中文网

    PHP中文网2017-06-26 10:54:06

    transform does not support inline elements~

    reply
    0
  • 学习ing

    学习ing2017-06-26 10:54:06

    My test is supported.

    reply
    0
  • 世界只因有你

    世界只因有你2017-06-26 10:54:06

    Are you sure you can’t rotate? ? I tried it and it works

    reply
    0
  • Cancelreply