[英]CSS/JS/HTML: JS Function to rotate full page?
Okay, so for my final in a web class, we are just supposed to make a website do whatever we went. 好的,所以对于我在网络课上的决赛,我们应该让网站做我们去的任何事情。 I'm done now and decided to add some fun stuff.
我现在已经完成并决定添加一些有趣的东西。
I want to use -webkit-transform: rotate(-4deg)
; 我想使用
-webkit-transform: rotate(-4deg)
; on the body. 在身体上。
How can I do that in a javascript function? 我怎么能在javascript函数中做到这一点? I have done it with the body background before, but I cannot get this to work.
我以前用身体背景做过,但我不能让它起作用。
Here is what I tried: 这是我尝试过的:
function rotatepage() {
document.body.style.-webkit-transform = rotate(-90deg);
}
and 和
function rotatepage() {
document.body.style = -webkit-transform:rotate(-90deg);
}
Any ideas? 有任何想法吗? Is this possible?
这可能吗?
document.body.style.setProperty("-webkit-transform", "rotate(-90deg)", null);
You'll have to experiment in whatever browser you're using, but I found that the styles were named such that I needed to change document.body.style.MozTransform="rotate(4deg)"
, which means there's a fair chance you need to be changing document.body.style.WebkitTransform = rotate(-90deg);
您将不得不尝试使用您正在使用的任何浏览器,但我发现这些样式的名称是我需要更改
document.body.style.MozTransform="rotate(4deg)"
,这意味着你document.body.style.MozTransform="rotate(4deg)"
可能需要更改document.body.style.WebkitTransform = rotate(-90deg);
Remember, javascript very much doesn't like things like '-'
in variable names... 请记住,javascript非常不喜欢变量名中的
'-'
类的东西......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.