2014-10-16 76 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