繁体   English   中英

如何使用CSS旋转文字

[英]How to rotate text using CSS

无法旋转文本。 灰色div宽度必须为50。使用Chrome。

http://jsfiddle.net/NLfaz/1/

HTML:

<div class="divContactInfo">
    <div class="tabHeader">
        <span class="textRotate">My Contact Info</span>
    </div>
</div>

CSS:

.divContactIno
{
position:fixed;
    right:0;
    border:1px solid red;
    top:49%;
    width:350px;
    height:500px;
}
.divContactInfo .tabHeader
{
border:1px solid gray;
    width:50px;
    height:120px;
}
.textRotate
{
  -webkit-trasform:rotate(-90deg);
    -moz-trasform:rotate(-90deg);
}

您不能旋转内联元素,并且需要正确拼写transform

.textRotate {
    display: inline-block;
    -webkit-transform:rotate(-90deg);
    -moz-transform:rotate(-90deg);
}

请注意,您还将divContactInfo拼写为divContactIno

http://jsfiddle.net/mattball/R7bQn/

回应您的评论。尝试

.textRotate {
    display: block;
    white-space: pre;
    left: 10px;
    margin-top: 80px;

    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    transform: rotate(-90deg);
    }

尝试添加属性display ,然后使用旋转:

.divContactInfo
{
position:fixed;
    right:0;
    border:1px solid red;
    top:49%;
    width:350px;
    height:500px;
}
.divContactInfo .tabHeader
{
border:1px solid gray;
    width:50px;
    height:120px;
}


.textRotate {
display:block;
/* Safari */
-webkit-transform: rotate(-90deg);

/* Firefox */
-moz-transform: rotate(-90deg);

/* IE */
-ms-transform: rotate(-90deg);

/* Opera */
-o-transform: rotate(-90deg);

/* Internet Explorer */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);

}

http://jsfiddle.net/NLfaz/3/

    .divContactInfo
    {
    position:fixed;
        right:0;
        border:1px solid red;
        top:49%;
        width:350px;
        height:500px;
    }
    .divContactInfo .tabHeader
    {
    border:1px solid gray;
        width:50px;
        height:120px;
    }
    .textRotate
    {
        display:block;
      -webkit-transform:rotate(-90deg);
        -moz-transform:rotate(-90deg);
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM