2017-03-08 97 views
0

我有以下部分與高透明度的PNG背景圖像。我這樣做是因爲我不知道如何使用不透明度功能。我甚至沒有讓懸停鏈接顏色更改工作。我想這有什麼問題的CSS語法。鏈接懸停關閉不透明

無論如何,我真正想要的是當鼠標傳遞鏈接時關閉背景圖像不透明度。我怎樣才能做到這一點?

enter image description here

https://jsfiddle.net/h0b8e3t2/

<!-- 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} 

回答

1

你可以使用僞元素來解決這個問題,並使用正常的,非透明的PNG

.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; 
 
}
<!-- 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更新註釋:第二樣品

.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 */ 
 
}
<!-- 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>

+0

完美解決什麼我打算做...謝謝! – Pumizo

+0

任何機會有鏈接懸停白色背景? – Pumizo

+0

@Pumizo是的,什麼應該有白色背景? – LGSon