简体   繁体   English

如何只旋转背景180度,(不旋转字体)

[英]how to only rotate the background 180 deg,(not rotate the font)

this is my code: 这是我的代码:

<style type='text/css'>
    div {
    width: 100px;
    height: 100px;
    text-align: center;
    font-size: 22px;
    background-image: -webkit-gradient(linear, left top, left bottom,
                    color-stop(0.40, #ff0),
                    color-stop(0.5, orange),
                    color-stop(0.60, rgb(255, 0, 0)));
    -webkit-transform: rotate(180deg)
}
</style>
    <div id="test">click me to play</div>

the div rotate 180 deg , and the font is also rotate 180 deg, div旋转180度,字体也旋转180度,

but , i don't want the font rotate , 但是,我不希望字体旋转,

what can i do . 我能做什么 。

thanks 谢谢

unfortunately there's no existing solution yet! 遗憾的是还没有现有的解决方案! You either rotate the whole block (content, font and background included) or you don't rotate it. 您可以旋转整个块(包括内容,字体和背景),也可以不旋转它。 Sorry! 抱歉!

You can find documentation on these two websites: 您可以在以下两个网站上找到文档:

The later one offers a 'trick' solution that maybe could help, creating a 'fake' block containing your background. 后者提供了一个“技巧”解决方案,可能会有所帮助,创建一个包含背景的“假”块。

#myelement  
{  
position: relative;  
overflow: hidden;  
-webkit-transform: rotate(30deg);  
-moz-transform: rotate(30deg);  
-ms-transform: rotate(30deg);  
-o-transform: rotate(30deg);  
transform: rotate(30deg);  
}  
#myelement:before  
{  
content: "";  
position: absolute;  
width: 200%;  
height: 200%;  
top: -50%;  
left: -50%;  
z-index: -1;  
background: url(background.png) 0 0 repeat;  
-webkit-transform: rotate(-30deg);  
-moz-transform: rotate(-30deg);  
-ms-transform: rotate(-30deg);  
-o-transform: rotate(-30deg);  
transform: rotate(-30deg);  
}  

(source by sitepoint) (来自sitepoint)

Why rotate it at all? 为什么要旋转呢? Just describe your gradient the other way round: 只是反过来描述你的渐变:

background-image: -webkit-gradient(linear, left bottom, left top,
                color-stop(0.40, #ff0),
                color-stop(0.5, orange),
                color-stop(0.60, rgb(255, 0, 0)));

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

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