5

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?

3

2 Answers 2

4

Today I learned:

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

Fiddle'd

Sign up to request clarification or add additional context in comments.

Comments

0

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...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.