Vertical text in IE7, IE8, IE9, and IE10 with CSS only

后端 未结 3 1909
南旧
南旧 2021-02-02 00:35

Does anyone know how to successfully implement vertical text in IE7, IE8, IE9, and IE10 with CSS only? (by vertical text, I\'m referring to text being rotated counterclockwise

相关标签:
3条回答
  • 2021-02-02 01:21

    Here is pure CSS ( + 1 extra div for every text ) solution

    Works for all IE versions IE7-10

    /** 
     * Works everywere ( IE7+, FF, Chrome, Safari, Opera )
     */
    .rotated-text {
        display: inline-block;
        overflow: hidden;
        width: 1.5em;
    }
    .rotated-text__inner {
        display: inline-block;
        white-space: nowrap;
        /* this is for shity "non IE" browsers
           that doesn't support writing-mode */
        -webkit-transform: translate(1.1em,0) rotate(90deg);
           -moz-transform: translate(1.1em,0) rotate(90deg);
             -o-transform: translate(1.1em,0) rotate(90deg);
                transform: translate(1.1em,0) rotate(90deg);
        -webkit-transform-origin: 0 0;
           -moz-transform-origin: 0 0;
             -o-transform-origin: 0 0;
                transform-origin: 0 0;
       /* IE9+ */
       -ms-transform: none;
       -ms-transform-origin: none;
       /* IE8+ */
       -ms-writing-mode: tb-rl;
       /* IE7 and below */
       *writing-mode: tb-rl;
    }
    .rotated-text__inner:before {
        content: "";
        float: left;
        margin-top: 100%;
    }
    
    /* mininless css that used just for this demo */
    .container {
      float: left;
    }
    

    HTML example

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=utf-8 />
    <title>JS Bin</title>
    </head>
    <body>
      <div class="container">
        <div class="rotated-text"><span class="rotated-text__inner">Easy</span></div>
      </div>
       <div class="container">
        <div class="rotated-text"><span class="rotated-text__inner">Normal</span></div>
         </div>
       <div class="container">
        <div class="rotated-text"><span class="rotated-text__inner">Hard</span></div>
    </div>
    </body>
    </html>
    

    source: https://gist.github.com/obenjiro/7406727

    0 讨论(0)
  • 2021-02-02 01:29

    Having the same problem, but with additional bad readability of the rotated text, I would advice not to use the:

    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);

    for IE9 or IE 8.

    That's, what worked for me:

    p.css-vertical-text {
        color:#333;
        border:0px solid red;
        writing-mode:tb-rl;
        -webkit-transform:rotate(90deg);
        -moz-transform:rotate(90deg);
        -o-transform: rotate(90deg);
        white-space:nowrap;
        display:block;
        bottom:0;
        width:20px;
        height:20px;
        font-family: ‘Trebuchet MS’, Helvetica, sans-serif;
        font-size:24px;
        font-weight:normal;
        text-shadow: 0px 0px 1px #333;
    }
    

    from http://scottgale.com/css-vertical-text/2010/03/01/

    0 讨论(0)
  • 2021-02-02 01:38

    You should use conditionnal comment for older IEs .
    That what they are meant for and it will do no hurts nor hack (ing head) s :)

    0 讨论(0)
提交回复
热议问题