CSS/JS/HTML: JS Function to rotate full page?

10,361

Today I learned:

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

Fiddle'd

Share:
10,361
user802609
Author by

user802609

Updated on June 04, 2022

Comments

  • user802609
    user802609 almost 2 years

    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?