如何修复IOS上的CSS转换错误?

时间:2018-10-03 17:23:27

标签: ios css transition

我正在使用Apple风格的移动菜单。在Windows上正常运行时,在IOS上它返回一个转换错误(强大的闪烁)。我在iPad和MacBook上都测试了IOS,所以我认为这不是硬件问题。

我隔离了错误。如果我从下面的几行中删除了function onBackKeyDown(event) { event.preventDefault(); } ease-out属性,则该转换在IOS上可以正常运行:

ease-in

代码确实具有IOS必需的.window .header { transition: all 0.5s ease-out, background 1s ease-out; -webkit-transition: all 0.5s ease-out, background 1s ease-out; } .window .header.menu-opened { transition: all 0.3s ease-in, background 0.5s ease-in; -webkit-transition: all 0.3s ease-in, background 0.5s ease-in; } 前缀。因此,我不确定如何保留属性并修复过渡错误。

-webkit-
(function() {
    var burger = document.querySelector(".burger-container"),
        header = document.querySelector(".header");

    burger.onclick = function() {
        header.classList.toggle("menu-opened");
    };
})();
@import url(https://fonts.googleapis.com/css?family=Ek+Mukta:200);
body {
  margin: 0;
  line-height: 1.4;
  background: #E1E1E1;
}

.window {
  position: relative;
  display: block;
  width: 360px;
  height: 567px;
  margin: 100px auto 0;
  box-shadow: 0 0 65px 15px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  border-radius: 3px;
  background: #F1F1F1;
}
.window .header {
  position: absolute;
  display: block;
  top: 0;
  left: 0;
  height: 50px;
  width: 100%;
  background: rgba(0, 0, 0, 0.8);
  overflow: hidden;
  transition: all 0.5s ease-out, background 1s ease-out;
  -webkit-transition: all 0.5s ease-out, background 1s ease-out;
  transition-delay: 0.2s;
  z-index: 1;
}
.window .header .burger-container {
  position: relative;
  display: inline-block;
  height: 50px;
  width: 50px;
  cursor: pointer;
  -webkit-transform: rotate(0deg);
          transform: rotate(0deg);
  transition: all 0.3s cubic-bezier(0.4, 0.01, 0.165, 0.99);
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.window .header .burger-container #burger {
  width: 18px;
  height: 8px;
  position: relative;
  display: block;
  margin: -4px auto 0;
  top: 50%;
}
.window .header .burger-container #burger .bar {
  width: 100%;
  height: 1px;
  display: block;
  position: relative;
  background: red;
  transition: all 0.3s cubic-bezier(0.4, 0.01, 0.165, 0.99);
  transition-delay: 0s;
}
.window .header .burger-container #burger .bar.topBar {
  -webkit-transform: translateY(0px) rotate(0deg);
          transform: translateY(0px) rotate(0deg);
}
.window .header .burger-container #burger .bar.btmBar {
  -webkit-transform: translateY(6px) rotate(0deg);
          transform: translateY(6px) rotate(0deg);
}
.window .header .icon {
  display: inline-block;
  position: absolute;
  height: 100%;
  line-height: 50px;
  width: 50px;
  height: 50px;
  text-align: center;
  color: #FFF;
  font-size: 22px;
  left: 50%;
  -webkit-transform: translateX(-50%);
          transform: translateX(-50%);
}
.window .header .icon.icon-bag {
  right: 0;
  top: 0;
  left: auto;
  -webkit-transform: translateX(0px);
          transform: translateX(0px);
  transition: -webkit-transform 0.5s cubic-bezier(0.4, 0.01, 0.165, 0.99);
  transition: transform 0.5s cubic-bezier(0.4, 0.01, 0.165, 0.99);
  transition: transform 0.5s cubic-bezier(0.4, 0.01, 0.165, 0.99), -webkit-transform 0.5s cubic-bezier(0.4, 0.01, 0.165, 0.99);
  transition-delay: 0.65s;
}
.window .header ul.menu {
  position: relative;
  display: block;
  padding: 0px 48px 0;
  list-style: none;
}
.window .header ul.menu li.menu-item {
  border-bottom: 1px solid #333;
  margin-top: 5px;
  -webkit-transform: scale(1.15) translateY(-30px);
          transform: scale(1.15) translateY(-30px);
  opacity: 0;
  transition: opacity 0.6s cubic-bezier(0.4, 0.01, 0.165, 0.99), -webkit-transform 0.5s cubic-bezier(0.4, 0.01, 0.165, 0.99);
  transition: transform 0.5s cubic-bezier(0.4, 0.01, 0.165, 0.99), opacity 0.6s cubic-bezier(0.4, 0.01, 0.165, 0.99);
  transition: transform 0.5s cubic-bezier(0.4, 0.01, 0.165, 0.99), opacity 0.6s cubic-bezier(0.4, 0.01, 0.165, 0.99), -webkit-transform 0.5s cubic-bezier(0.4, 0.01, 0.165, 0.99);
}
.window .header ul.menu li.menu-item:nth-child(1) {
  transition-delay: 0.49s;
}
.window .header ul.menu li.menu-item:nth-child(2) {
  transition-delay: 0.42s;
}
.window .header ul.menu li.menu-item:nth-child(3) {
  transition-delay: 0.35s;
}
.window .header ul.menu li.menu-item:nth-child(4) {
  transition-delay: 0.28s;
}
.window .header ul.menu li.menu-item:nth-child(5) {
  transition-delay: 0.21s;
}
.window .header ul.menu li.menu-item:nth-child(6) {
  transition-delay: 0.14s;
}
.window .header ul.menu li.menu-item:nth-child(7) {
  transition-delay: 0.07s;
}
.window .header ul.menu li.menu-item a {
  display: block;
  position: relative;
  color: black;
  font-family: "Ek Mukta", sans-serif;
  font-weight: 100;
  text-decoration: none;
  font-size: 22px;
  line-height: 2.35;
  font-weight: 200;
  width: 100%;
}
.window .header.menu-opened {
  height: 100%;
  background-color: white;
  transition: all 0.3s ease-in, background 0.5s ease-in;
  -webkit-transition: all 0.3s ease-in, background 0.5s ease-in;
  transition-delay: 0.25s;
}
.window .header.menu-opened .burger-container {
  -webkit-transform: rotate(90deg);
          transform: rotate(90deg);
}
.window .header.menu-opened .burger-container #burger .bar {
  transition: all 0.4s cubic-bezier(0.4, 0.01, 0.165, 0.99);
  transition-delay: 0.2s;
}
.window .header.menu-opened .burger-container #burger .bar.topBar {
  -webkit-transform: translateY(4px) rotate(45deg);
          transform: translateY(4px) rotate(45deg);
}
.window .header.menu-opened .burger-container #burger .bar.btmBar {
  -webkit-transform: translateY(3px) rotate(-45deg);
          transform: translateY(3px) rotate(-45deg);
}
.window .header.menu-opened ul.menu li.menu-item {
  -webkit-transform: scale(1) translateY(0px);
          transform: scale(1) translateY(0px);
  opacity: 1;
}
.window .header.menu-opened ul.menu li.menu-item:nth-child(1) {
  transition-delay: 0.27s;
}
.window .header.menu-opened ul.menu li.menu-item:nth-child(2) {
  transition-delay: 0.34s;
}
.window .header.menu-opened ul.menu li.menu-item:nth-child(3) {
  transition-delay: 0.41s;
}
.window .header.menu-opened ul.menu li.menu-item:nth-child(4) {
  transition-delay: 0.48s;
}
.window .header.menu-opened ul.menu li.menu-item:nth-child(5) {
  transition-delay: 0.55s;
}
.window .header.menu-opened ul.menu li.menu-item:nth-child(6) {
  transition-delay: 0.62s;
}
.window .header.menu-opened ul.menu li.menu-item:nth-child(7) {
  transition-delay: 0.69s;
}
.window .header.menu-opened .icon.icon-bag {
  -webkit-transform: translateX(75px);
          transform: translateX(75px);
  transition-delay: 0.3s;
}
.window .content {
  font-family: "Ek Mukta", sans-serif;
  padding: 67px 4% 0;
  text-align: justify;
  overflow: scroll;
  max-height: 100%;
  background-color: grey;
}
.window .content::-webkit-scrollbar {
  display: none;
}
.window .content h2 {
  margin-bottom: 0px;
  letter-spacing: 1px;
}
.window .content img {
  width: 95%;
  position: relative;
  display: block;
  margin: 75px auto 75px;
}
.window .content img:nth-of-type(2) {
  margin: 75px auto;
}
@media (max-width: 600px) {
  .window {
    width: 100%;
    height: 100vh;
    margin: 0;
    border-radius: 0px;
  }
  .window .header {
    position: fixed;
  }
}

0 个答案:

没有答案