首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >链接悬停关闭不透明度

链接悬停关闭不透明度
EN

Stack Overflow用户
提问于 2017-03-08 22:28:18
回答 1查看 619关注 0票数 0

下面我有一个具有高透明度的png背景图像的部分。我是这样做的,因为我不知道如何使用不透明功能。我甚至未能使悬停链接的颜色改变到工作。我想css语法有问题。

不管怎么说,我真正想要的是关闭背景图像不透明度时,鼠标传递的链接。我怎么做这个?

https://jsfiddle.net/h0b8e3t2/

代码语言:javascript
复制
<!-- Jobs -->
            <section id="jobs" class="wrapper style5">
                <div class="inner">
                <a href="#" target="new"><p><strong>Would You Like To Join Our Team?</strong></p></a>
                </div>
            </section>

.wrapper.style5 {
            background-color: #fcf3f7;
            background-image: url("/images/join.png");
            background-repeat: repeat-y;
            background-size: contain;
            border-style:solid none none none;
            border-width: 1,5px;
            border-color: #a4a4a4;
            text-align: center;
            font-size: 50px;
            line-height: 120%;
            color: #fff;


        }

            #jobs .wrapper.style5:hover {color:#fff}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-08 22:49:17

您可以使用伪元素来解决这个问题,并使用一个正常的、不透明的png。

代码语言:javascript
复制
.wrapper.style5 {
  position: relative;
  border-style: solid none none none;
  border-width: 1, 5px;
  border-color: #a4a4a4;
  text-align: center;
  font-size: 50px;
  line-height: 120%;
  color: #fff;
}

.wrapper.style5 a::before,
.wrapper.style5 a::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fcf3f7;
  z-index: -1;
}
.wrapper.style5 a::after {
  background: url(http://lorempixel.com/500/200/nature/1/);
  background-repeat: repeat-x;
  background-size: contain;
  opacity: 0.1;
}

.wrapper.style5 a:hover {
  color: #fff;
}
.wrapper.style5 a:hover::after {
  opacity: 1;
}
代码语言:javascript
复制
<!-- Jobs -->
<section id="jobs" class="wrapper style5">
  <div class="inner">
    <a href="https://docs.google.com/forms/d/e/1FAIpQLScerklD64H1kq9lz2UK58fJXhyWllJf-_ISCfFV4ew5A538VQ/viewform" target="new">
      <p><strong>Would You Like To Join Our Team?</strong></p>
    </a>
  </div>
</section>

基于用2:nd示例更新的注释

代码语言:javascript
复制
.wrapper.style5 {
  position: relative;
  border-style: solid none none none;
  border-width: 1, 5px;
  border-color: #a4a4a4;
  text-align: center;
  font-size: 50px;
  line-height: 120%;
  color: #fff;
}

.wrapper.style5 a::before,
.wrapper.style5 a::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fcf3f7;
  z-index: -1;
}
.wrapper.style5 a::after {
  background: url(http://lorempixel.com/500/200/nature/1/);
  background-repeat: repeat-x;
  background-size: contain;
  opacity: 0.1;
}

.wrapper.style5 a:hover p {          /*  changed this  */
  background: #fff;                  /*  changed this  */
}
.wrapper.style5 a:hover::after {
  /* opacity: 1;                         removed this  */
}
代码语言:javascript
复制
<!-- Jobs -->
<section id="jobs" class="wrapper style5">
  <div class="inner">
    <a href="https://docs.google.com/forms/d/e/1FAIpQLScerklD64H1kq9lz2UK58fJXhyWllJf-_ISCfFV4ew5A538VQ/viewform" target="new">
      <p><strong>Would You Like To Join Our Team?</strong></p>
    </a>
  </div>
</section>

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

https://stackoverflow.com/questions/42683117

复制
相关文章

相似问题

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