最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - CSSJSHTML: JS Function to rotate full page? - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question edited May 24, 2012 at 7:29 j0k 22.8k28 gold badges81 silver badges90 bronze badges asked May 24, 2012 at 6:40 user802609user802609 8096 gold badges20 silver badges35 bronze badges 3
  • I think this question is duplicated. find out here may can help you with this : stackoverflow./questions/708895/… – Kannika Commented May 24, 2012 at 6:59
  • 2 Meh, why does nobody see obvious syntax errors anymore nowadays? – ThiefMaster Commented May 24, 2012 at 7:14
  • possible duplicate of How to set the style -webkit-transform dynamically using Javascript? – Wladimir Palant Commented May 24, 2012 at 7:37
Add a ment  | 

2 Answers 2

Reset to default 4

Today I learned:

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

Fiddle'd

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);

Remember, javascript very much doesn't like things like '-' in variable names...

发布评论

评论列表(0)

  1. 暂无评论