2014-10-16 86 views
0

我希望能夠在按鈕懸停時更改按鈕內的文本。文字只是在它被覆蓋時才改變顏色,而不是整個按鈕。該按鈕的背景應該是#FFFFFF和文字顏色應該是#3A75B0如何在突出顯示按鈕時更改按鈕內的文本?

HTML:

<div class="getStartedButton"> 
     <a href ="/signup"> 
      <button class="getStarted"> 
       Get Started 
      </button> 
     </a> 
</div> 

CSS:

.getStarted { 
    display: table; 
    margin: 0 auto !important; 
    height: 170px; 
    width: 300px; 
    background: transparent; 
    text-decoration: none; 
    border-style: solid; 
    border-color: #FFFFFF; 
    font-family: Helvetica; 
    text-align: center; 
    color: #FFFFFF; 
    -webkit-border-radius: 10px; 
    -moz-border-radius: 10px; 
    border-radius: 10px; 
    font-size: 60px; 
    padding: 20px 10px 50px 10px; 
    margin-bottom: 50px; 
} 

.getStarted a { 
    text-decoration: none; 
    font-family: Helvetica; 
    text-align: center; 
    color: #FFFFFF; 
    font-size: 60px; 
    margin-bottom: 50px; 
} 

a:link { 
    text-decoration: none; 
} 

a:visited { 
    text-decoration: none; 
} 


.getStartedButton:hover { 
    color: #3A75B0; 
    background-color: #FFFFFF; 
} 

.getStartedButton { 
    width: 300px; 
    margin-left: auto; 
    margin-right: auto; 
    border-radius: 10px; 
} 

.getStartedButton a:hover { 
    color: #3A75B0; 
} 

.getStarted:hover { 
    color: #3A75B0; 
} 

.getStartedButton.getStarted:hover { 
    color: #3A75B0; 
} 

回答

0

這是不可能的純CSS。試試這個JS方法:

function changeText(button){ 
 
    
 
    button.innerHTML = "Text Changed!"; 
 
    
 
    }
<div class="getStartedButton"> 
 
     <a href ="/signup"> 
 
      <button onmouseover="changeText(this)" class="getStarted"> 
 
       Get Started 
 
      </button> 
 
     </a> 
 
</div>

希望對你有用!

+0

沒有problemo,夥計。 – 2014-10-17 00:00:13

相關問題