0

我正在做一个大型项目,我必须针对整个网站的按钮和链接的键盘焦点状态。这是一个非常大的网站,并且创建了很多年的链接。

我已经设法定位按钮和特定的动画链接(参见键盘导航示例),但我似乎无法定位其他链接或ul > li > a链接。

我如何定位这些其他链接?

/* Duru Sans */
@import url("https://fonts.googleapis.com/css2?family=Duru+Sans&display=swap");
/*resets*/
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: "Duru Sans", sans-serif;
  font-size: 16px;
}

.container {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  height: 60vh;
}

a {
  text-decoration: none;
}
a.nextiva-bttn-anim {
  align-items: center;
  border: 0;
  border-radius: 4px;
  box-shadow: 0px 12px 30px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: inline-flex;
  font-size: 1.062rem;
  font-weight: 700;
  justify-content: center;
  min-width: 185px;
  outline: 0;
  padding: 1.25rem 0;
  position: relative;
  text-transform: none;
  transition: all 0.2s ease;
}
a.nextiva-bttn-anim:hover {
  box-shadow: 0px 8px 12px rgba(0, 0, 0, 0.08);
}
a.nextiva-bttn-anim:before {
  content: "";
  position: absolute;
  border: solid 0px #005fec;
  top: 0px;
  bottom: 0px;
  left: 0px;
  right: 0px;
  opacity: 0;
  transition: all 0.2s ease;
  border-radius: 4px;
  filter: blur(4px);
}
a.nextiva-bttn-anim:focus-visible:before {
  content: "";
  position: absolute;
  border: solid 2px #005fec;
  top: -8px;
  bottom: -8px;
  left: -8px;
  right: -8px;
  opacity: 1;
  filter: blur(0px);
}
a.nextiva-blue-bttn {
  background: #005fec;
  color: white;
}
a.white {
  background: white;
  color: #005fec;
}
a.nextiva-bttn-anim .bttn-txt {
  color: inherit;
  font-weight: inherit;
  display: inline-block;
  transform: translateX(0.625rem);
  transition: transform 0.2s;
}
a.nextiva-bttn-anim .learn-more-arrow {
  height: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
a.nextiva-bttn-anim:hover .bttn-txt {
  transform: translate(0px);
  transition: transform 0.2s;
  margin-right: 0.3rem;
}
a.nextiva-bttn-anim:hover .learn-more-arrow {
  opacity: 1;
  transition: opacity 0.2s, transform 0.2s;
}

.txt-link a::before {
  content: "";
  position: absolute;
  border: solid 0px #005fec;
  top: 0px;
  bottom: 0px;
  left: 0px;
  right: 0px;
  opacity: 0;
  transition: all 0.2s ease;
  border-radius: 4px;
  filter: blur(4px);
}

*:focus {
  outline: none;
}

.txt-link a:focus-visible:before {
  content: "";
  position: absolute;
  border: solid 2px #005fec;
  top: -8px;
  bottom: -8px;
  left: -8px;
  right: -8px;
  opacity: 1;
  filter: blur(0px);
}

.txt-link a:focus-visible:before {
  left: -4px;
  right: -4px;
}

.txt-link {
  display: inline-flex;
  font-size: 1.25rem;
  align-items: center;
}
.txt-link a {
  color: #005fec;
  font-weight: 700;
  font-size: 1.25rem;
  position: relative;
  text-decoration: none;
}
.txt-link a:hover::after {
  visibility: visible;
  width: 100%;
}
.txt-link a::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: #005fec;
  visibility: hidden;
  transition: all 0.2s ease;
}
.txt-link img {
  height: 0.75rem;
  margin-left: 0.5rem;
}
  <div class="container">
  <a class="nextiva-bttn-anim nextiva-blue-bttn light" href="#">
    <span class="bttn-txt">Small business</span>
    <img src="https://nextivaweb.imgix.net/icons/Arrow-Right-Hover-Animation_white.svg" alt="right arrow icon" class="learn-more-arrow">
  </a>

  <span class="txt-link arrow-link">
    <a href="#">See all-in-one</a>
    <img alt="arrow right icon" class="learn-more-arrow" src="https://nextivaweb.imgix.net/icons/Arrow-Right-Hover-Animation.svg" loading="lazy">
  </span>

  <a href="#" class="link-ct">Learn more</a>
  
  <div class="lnks">
    <ul class="company">
      <li><a href="#">Hello</a></li>
    </ul>
  </div>

  <a class="nextiva-bttn-anim white" href="#">
    <span class="bttn-txt">Enterprise</span>
    <img src="https://nextivaweb.imgix.net/icons/Arrow-Right-Hover-Animation.svg" alt="right arrow icon" class="learn-more-arrow" loading="lazy">
  </a>
</div>

4

1 回答 1

1

您可以尝试省略::before伪选择器,然后它可以工作:

/* Duru Sans */
@import url("https://fonts.googleapis.com/css2?family=Duru+Sans&display=swap");
/*resets*/
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: "Duru Sans", sans-serif;
  font-size: 16px;
}

.container {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  height: 60vh;
}

a {
  text-decoration: none;
}
a.nextiva-bttn-anim {
  align-items: center;
  border: 0;
  border-radius: 4px;
  box-shadow: 0px 12px 30px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: inline-flex;
  font-size: 1.062rem;
  font-weight: 700;
  justify-content: center;
  min-width: 185px;
  outline: 0;
  padding: 1.25rem 0;
  position: relative;
  text-transform: none;
  transition: all 0.2s ease;
}
a.nextiva-bttn-anim:hover {
  box-shadow: 0px 8px 12px rgba(0, 0, 0, 0.08);
}
a.nextiva-bttn-anim:before {
  content: "";
  position: absolute;
  border: solid 0px #005fec;
  top: 0px;
  bottom: 0px;
  left: 0px;
  right: 0px;
  opacity: 0;
  transition: all 0.2s ease;
  border-radius: 4px;
  filter: blur(4px);
}
a.nextiva-bttn-anim:focus-visible:before {
  content: "";
  position: absolute;
  border: solid 2px #005fec;
  top: -8px;
  bottom: -8px;
  left: -8px;
  right: -8px;
  opacity: 1;
  filter: blur(0px);
}
a.nextiva-blue-bttn {
  background: #005fec;
  color: white;
}
a.white {
  background: white;
  color: #005fec;
}
a.nextiva-bttn-anim .bttn-txt {
  color: inherit;
  font-weight: inherit;
  display: inline-block;
  transform: translateX(0.625rem);
  transition: transform 0.2s;
}
a.nextiva-bttn-anim .learn-more-arrow {
  height: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
a.nextiva-bttn-anim:hover .bttn-txt {
  transform: translate(0px);
  transition: transform 0.2s;
  margin-right: 0.3rem;
}
a.nextiva-bttn-anim:hover .learn-more-arrow {
  opacity: 1;
  transition: opacity 0.2s, transform 0.2s;
}

.txt-link a::before {
  content: "";
  position: absolute;
  border: solid 0px #005fec;
  top: 0px;
  bottom: 0px;
  left: 0px;
  right: 0px;
  opacity: 0;
  transition: all 0.2s ease;
  border-radius: 4px;
  filter: blur(4px);
}

*:focus {
  outline: none;
}

.txt-link a:focus-visible:before {
  content: "";
  position: absolute;
  border: solid 2px #005fec;
  top: -8px;
  bottom: -8px;
  left: -8px;
  right: -8px;
  opacity: 1;
  filter: blur(0px);
}

.txt-link a:focus-visible:before {
  left: -4px;
  right: -4px;
}

.txt-link {
  display: inline-flex;
  font-size: 1.25rem;
  align-items: center;
}
.txt-link a {
  color: #005fec;
  font-weight: 700;
  font-size: 1.25rem;
  position: relative;
  text-decoration: none;
}
.txt-link a:hover::after {
  visibility: visible;
  width: 100%;
}
.txt-link a::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: #005fec;
  visibility: hidden;
  transition: all 0.2s ease;
}
.txt-link img {
  height: 0.75rem;
  margin-left: 0.5rem;
}

ul li a:focus-visible{
  border: solid 2px #005fec;
  top: -8px;
  bottom: -8px;
  left: -8px;
  right: -8px;
  opacity: 1;
  filter: blur(0px);
  border-radius: 4px;
  transition: all 0.2s ease;
}
<div class="container">
  <a class="nextiva-bttn-anim nextiva-blue-bttn light" href="#">
    <span class="bttn-txt">Small business</span>
    <img src="https://nextivaweb.imgix.net/icons/Arrow-Right-Hover-Animation_white.svg" alt="right arrow icon" class="learn-more-arrow">
  </a>

  <span class="txt-link arrow-link">
    <a href="#">See all-in-one</a>
    <img alt="arrow right icon" class="learn-more-arrow" src="https://nextivaweb.imgix.net/icons/Arrow-Right-Hover-Animation.svg" loading="lazy">
  </span>

  <a href="#" class="link-ct">Learn more</a>
  
  <div class="lnks">
    <ul class="company">
      <li><a href="#">Hello</a></li>
    </ul>
  </div>

  <a class="nextiva-bttn-anim white" href="#">
    <span class="bttn-txt">Enterprise</span>
    <img src="https://nextivaweb.imgix.net/icons/Arrow-Right-Hover-Animation.svg" alt="right arrow icon" class="learn-more-arrow" loading="lazy">
  </a>
</div>

于 2021-07-17T05:48:20.843 回答