4

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); on the body.

How can I do that in a javascript function? 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?

4

2 回答 2

4

今天我学到了

document.body.style.setProperty("-webkit-transform", "rotate(-90deg)", null);

摆弄

于 2012-05-24T07:11:31.990 回答
0

您必须在使用的任何浏览器中进行试验,但我发现样式被命名为我需要更改document.body.style.MozTransform="rotate(4deg)",这意味着您很有可能需要更改document.body.style.WebkitTransform = rotate(-90deg);

请记住,javascript 非常不喜欢'-'变量名之类的东西......

于 2012-05-24T06:57:00.080 回答