Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Safari + CSS calc() + CSS transition = Instant Crash

When I try to use left: -webkit-calc(100% - 100px); (assuming that left: 0; is initial state) it works in iOS 6.0.1 just fine. But when I do the same with transition: left 1s linear; it instantly crashes Safari, every single time. Is it known bug or am I doing something wrong?

It also doesn't work in Safari 5 (no reaction). But it works in Firefox and Chrome.

like image 838
Atadj Avatar asked Dec 27 '12 13:12

Atadj


3 Answers

You can fix this by initialising the property with anything but auto:

.menu {
  left: 0;
  transition: left 1s linear;
}

.menu-open .menu {
  left: -webkit-calc(100% - 50px);
  left: calc(100% - 50px);
}
like image 76
Guido Bouman Avatar answered Sep 29 '22 12:09

Guido Bouman


This has been a WebKit bug for some time now. For now you can use JS to accomplish the same end effect.

like image 45
Mooseman Avatar answered Sep 29 '22 12:09

Mooseman


None of the answers posted thus far worked for me.

What did work was working around the calc statement using negative margin:

#example {
  left: 100%;
  margin-left: -100px;
}
like image 23
Choylton B. Higginbottom Avatar answered Sep 29 '22 10:09

Choylton B. Higginbottom