首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从此转换代码中移除z索引。

从此转换代码中移除z索引。
EN

Stack Overflow用户
提问于 2021-07-07 03:55:16
回答 1查看 103关注 0票数 0

我将如何对代码进行重组,以便在转换过程中不需要z索引?

没有z-索引:https://jsfiddle.net/Legcb42d/

代码语言:javascript
复制
.container1 {
  position: relative;
  width: 100%;
  height: 100%;
}

.container1.slide {
  height: auto;
  min-height: 100%;
  overflow: hidden;
}

.door-left,
.door-right {
  position: absolute;
  height: 100%;
  width: 50%;
  top: 0%;
  transition: all ease 8s;
}

.door-left {
  left: 0%;
  background-color: rgb(91, 96, 106);
}

.door-right {
  left: 50%;
  background-color: rgb(229, 211, 211);
}

.container1.slide .door-left {
  left: -50%;
}

.container1.slide .door-right {
  left: 100%;
}

<div class="container1 ">
<div class="door-left"></div>
<div class="door-right"></div>

(function iife() {
  "use strict";

  function show(el) {
    el.classList.remove("hide");
    document.querySelector(".container1").classList.add('slide');
  }

  function hide(el) {
    el.classList.add("hide");
  }

  function coverClickHandler(evt) {
    const cover = evt.currentTarget;
    const thewrap = cover.parentNode.querySelector(".container");
    hide(cover);
    show(thewrap);
  }
  const cover = document.querySelector(".jacketa");
  cover.addEventListener("click", coverClickHandler);
}());

,不应该是这样的。

没有z-索引:https://jsfiddle.net/Legcb42d/

,这就是它应该看到的样子.

With z-index:https://jsfiddle.net/rspxkyoL/

EN

回答 1

Stack Overflow用户

发布于 2021-07-07 04:14:07

为什么不是z-index?如果您认为播放按钮将隐藏,如果您增加它的门,那么你也可以增加播放按钮的z索引。

添加z-索引

代码语言:javascript
复制
.door-left,
.door-right {
   ...
   z-index: 1;
}

.jacketa {
   ...
   z-index: 2;
}

这是一个工作的小提琴

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68279783

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档