3

I have div, and the css is like below

.container {
    width: 100%;
    height: 100%;
    transition: 0.5s;
    transform-style: preserve-3d; 
    transform: rotateY(0deg) translateZ(-404.747px);
}

and now, I want use jQuery to change the transform property to

transfrom: rotateY(-40deg) translateZ(-404.747px);

if I use

$('.container').css('transform', 'rotateY(-40deg) translateZ(-404.747px)');

then 'translateZ(-404.747px)' will take action again. So, my question is how can I change the value of rotateY(), without change the 'translateZ()' ?

2
  • Well I am not sure about the real implementation BUT what you could do without having a major issue is to wrap another element around it and then apply the rotateY - if that is sufficient for you. Commented Dec 27, 2014 at 12:43
  • just apply rotateY(-40deg) on container class.... Commented Dec 27, 2014 at 12:44

2 Answers 2

1

just plop it in the style attr!

$('.container').css('transform', 'rotateY(-40deg)');
Sign up to request clarification or add additional context in comments.

Comments

0
<div class="container remove"></div>

.container {
    width: 100%;
    height: 100%;
    transition: 0.5s;
    transform-style: preserve-3d; 
}

.add{
transfrom: rotateY(-40deg) translateZ(-404.747px);
}

.remove{
transform: rotateY(0deg) translateZ(-404.747px);
}

$('.container').removeclass('remove');
$('.container').addclass('add');

2 Comments

Thanks for all your answers, I found the 'translateZ(-404.747px)' will not take action agian, if I use $('.container').css('transform', 'rotateY(-40deg) translateZ(-404.747px)'); the real problem is the order of rotateY and translateZ will achieve different results. So I swap these two property, the issue solved.
@kebenhu, please provide your solution as an answer.

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.