单击tabindex =“ 0”元素内的链接时,焦点消失

时间:2019-10-21 20:30:06

标签: html css

我在CSS上创建了一个下拉列表,焦点存在问题,当单击链接时,我失去了整个容器的焦点。

这是通过将叉号更改为“菜单”来表示的。您如何解决?

理想情况下,我想在纯CSS上有一个菜单

您的帖子似乎主要是代码;请添加更多详细信息。

.aw_spoilerbox {
  outline: none;
  display: inline-block;
  font-family: "Reder", sans-serif;
  position: relative;
  text-align: left;
}

.aw_dark_cover:after {
  position: fixed;
  visibility: hidden;
  content: "";
  width: 100vw;
  height: 100vh;
  background: red;
  opacity: 0;
  left: 0;
  top: 0;
  z-index: -1;
  transition: all 0.15s ease-out;
}
.aw_spoilerbox:focus .aw_dark_cover:after,
.aw_spoiler:hover + .aw_dark_cover:after {
  visibility: visible;
  opacity: 0.8;
}

.aw_spoiler {
  position: absolute;
  visibility: hidden;
  transform: scale(0) translate(100%, 0);
  transition: all 0.15s ease-out;
  transform-origin: 100% 0;
  opacity: 0.5;
}

.aw_spoilerbox:focus .aw_spoiler,
.aw_spoiler:hover {
  visibility: visible;
  transform: scale(1) translate(0, 0);
  transform-origin: 0 0;
  opacity: 1;
}
.aw_spoilerbox:focus .aw_btn_menu_close {
  display: block;
  background-position: left bottom;
  color: black;
}
.aw_spoilerbox:focus .aw_btn_menu_open {
  display: none;
  opacity: 0;
}

.aw_btn_menu_close {
  display: none;
}
.aw_btn_menu_open {
  display: block;
}
.aw_spoilerbox > a {
  color: white;
  font-size: 1em;
  border: 1px solid white;
  line-height: 50px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease-out;
  background: linear-gradient(to right, WHITE 50%, transparent 50%);
  background-size: 200% 100%;
  background-position: right bottom;
  box-sizing: border-box;
  margin-right: 0.5px;
}

.aw_spoilerbox > a:hover {
  color: black;
  background-position: left bottom;
}

/* For main menu */

.aw_main_menu > a {
  width: 150px;
  clip-path: polygon(
    100% 0,
    100% calc(100% - 10px),
    calc(100% - 10px) 100%,
    0 100%,
    0 0
  );
}
.aw_main_menu > a:before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 10px 10px;
  border-color: transparent transparent white transparent;
}

.aw_main_menu > a:after {
  content: "";
  position: absolute;
  right: -1px;
  top: 0;
  width: 1px;
  height: 100%;
  background: white;
}

.aw_main_menu .aw_spoiler {
  background: white;
  width: 300px;
  margin-top: 10px;
  right: 12.5px;
}
.aw_menu_content {
  padding: 30px;
}

body {
  background: black;
  padding: 50px;
  text-align: right;
}
<div class="aw_spoilerbox aw_main_menu" tabindex="0">
  <a class="aw_btn_menu_open">MENU</a>
  <a tabindex="1" class="aw_btn_menu_close">✕</a>
  <div class="aw_spoiler">
    <div class="aw_menu_content">
      <ul>
        <li><a href="#">Menu #1</a></li>
        <li>Menu #2</li>
        <li>Menu #3</li>
      </ul>
    </div>
  </div>
  <div tabindex="0" class="aw_dark_cover"></div>
</div>

0 个答案:

没有答案