【问题标题】:Animated overlay not transitioning properly on iPad动画覆盖在 iPad 上无法正确过渡
【发布时间】:2018-02-27 05:31:06
【问题描述】:

我遇到了过渡叠加层的问题,在该叠加层完成过渡之前,不会显示背景和隐藏内容。 “示例标题”文本按照应有的方式进行动画处理。

预期行为是当用户将鼠标悬停在框/图像上时,包含文本和图像的绿色背景应向上过渡/滑动以覆盖框/图像。它在我测试过的所有浏览器上都按预期工作,只是在使用 Safari 和 Chrome 的 iPad 上没有。

您可以在此处找到示例: https://codepen.io/anon/pen/RQYXGo

h2 {
  margin-top: 20px;
  margin-bottom: 10px;
  font-family: inherit;
  font-weight: 500;
  line-height: 1.1;
  color: inherit;
  font-size: 30px;
}

h2,
p {
  margin: 0;
  padding: 0;
}

p {
  line-height: 1.5;
  font-size: 18px;
  font-weight: 400;
  padding-bottom: 10px;
}

a {
  color: #339752;
}

.btn-cta {
  background-color: #eed507;
  color: #000;
  text-transform: uppercase;
  border-radius: 0;
  border: none;
  border-bottom: 5px solid #dcb311;
  width: 85%;
  font-size: 24px;
  font-weight: 600;
  padding: 13px 15px;
}

.btn-cta:hover,
.btn-cta:focus,
.btn-cta:active {
  color: #333;
}

.col-md-5ths {
  position: relative;
  min-height: 1px;
  padding-right: 10px;
  padding-left: 10px;
}

.col-md-5ths {
  width: 20%;
  float: left;
}

.service {
  position: relative;
  overflow: hidden;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  text-align: center;
}

.service img.service-icon {
  display: block;
  margin: 15px auto;
}

.service p.service-text {
  padding: 0 10px 25px;
  text-align: center;
  font-size: 0.95vw;
}

.service .btn-cta {
  position: absolute;
  margin: 0 auto;
  left: 0;
  right: 0;
  bottom: 20px;
}

.service::before {
  content: ' ';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: transparent;
  transition: background 0.30s ease-out;
}

.service_media {
  display: block;
  min-width: 100%;
  max-width: 100%;
  height: auto;
}

.service_overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 10px 0;
  color: white;
  background-color: rgba(12, 48, 41, 0.9);
  -webkit-transform: translateY(100%);
  transform: translateY(100%);
  transition: -webkit-transform 0.30s ease-out;
  transition: transform 0.30s ease-out;
}

.service:hover .service_overlay {
  -webkit-transform: translateY(0);
  transform: translateY(0);
}

.service_overlay__title {
  text-align: center;
  padding: 30px 0;
  background-color: rgba(12, 48, 41, 0.9);
  -webkit-transform: translateY(-webkit-calc(-100% - 10px));
  transform: translateY(calc(-100% - 10px));
  transition: -webkit-transform 0.30s ease-out;
  transition: transform 0.30s ease-out;
}

.service:hover .service_overlay__title {
  -webkit-transform: translateY(0);
  transform: translateY(0);
  background-color: transparent;
}
<section class="all-services">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-5ths col-xs-6">
        <article class="service" onclick="">
          <img class="service_media" src="http://via.placeholder.com/360x500" alt="" />
          <div class="service_overlay">
            <h2 class="service_overlay__title">Example title</h2>
            <p class="service_overlay__content">
              <img class="service-icon" src="http://via.placeholder.com/80x80" alt="">
              <p class="service-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
              <a class="btn btn-cta" href="#">Read More</a></p>
          </div>
        </article>
</section>

我尝试使用背景而不是background-color 并在.service_overlay 中添加更高的z-index,但这似乎并没有改变任何东西。

它似乎在其他浏览器上运行良好,包括 Mac 上的 Safari。我知道这些都是试图解决问题的微不足道的尝试,但我真的无法弄清楚为什么这只是在 iPad 上发生。

我也在使用引导程序 3.3.7。

【问题讨论】:

    标签: html css twitter-bootstrap twitter-bootstrap-3


    【解决方案1】:

    想通了。将 .service_overlayposition: absolute 更改为 position: fixed 解决了 iPad 上的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-13
      • 1970-01-01
      • 2020-07-25
      相关资源
      最近更新 更多