简体   繁体   中英

How to keep the link color on CSS buttons as one color when changing default link colors?

I've searched for a similar question but either it's a glaring error I just can't see or I'm just bad at phrasing my searches.

So, I have an assignment to create a basic website however I've decided to go further and just create the business site I've desired then submit that, however, I've encountered a problem I can't seem to find a way around. Due to the fact my background is a little dark in my webpage I wanted to brighten the default link colors so they were still recognizable as links but easily legible. Having used CSS buttons for my menu, though, it changes the text color on the buttons too even though the text of it is explicitly set to white in the code of the buttons.

If you want to see any of what I'm talking about in action, there's a version of my site currently hosted here. This is the version with the brighter link colors.

As for my button's code, it looks like this:

.homebutton {
font-size:15px;
font-family:Georgia;
font-weight:normal;
color: #FFFFFF;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
border:1px solid #b33329;
padding:10px 30px;
text-decoration:none;
background:-webkit-gradient( linear, left top, left bottom, color-stop(21%, #cc372d), color-stop(84%, #8a2b23) );
background:-moz-linear-gradient( center top, #cc372d 21%, #8a2b23 84% );
background:-ms-linear-gradient( top, #cc372d 21%, #8a2b23 84% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#cc372d', endColorstr='#8a2b23');
background-color:#cc372d;
display:inline-block;
text-shadow:1px 1px 0px #810e05;
-webkit-box-shadow:inset 1px 1px 0px 0px #f5978e;
-moz-box-shadow:inset 1px 1px 0px 0px #f5978e;
box-shadow:inset 1px 1px 0px 0px #f5978e;
-webkit-box-sizing: border-box;
 -moz-box-sizing: border-box;
      box-sizing: border-box;
}

.homebutton:hover {
background:-webkit-gradient( linear, left top, left bottom, color-stop(21%, #8a2b23), color-stop(84%, #cc372d) );
background:-moz-linear-gradient( center top, #8a2b23 21%, #cc372d 84% );
background:-ms-linear-gradient( top, #8a2b23 21%, #cc372d 84% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#8a2b23', endColorstr='#cc372d');
background-color:#8a2b23;
-webkit-box-sizing: border-box;
 -moz-box-sizing: border-box;
      box-sizing: border-box;
}

.homebutton:active {
position:relative;
top:1px;
-webkit-box-sizing: border-box;
 -moz-box-sizing: border-box;
      box-sizing: border-box;
}

This is the exact CSS code for the 'home' button used on the webpage.

Any help or insight provided will be much appreciated and thanks for taking the time to look at my plea, at least haha.

-Sky

you need to define a rule to links inside your button, add this to your css

a.homebutton{
    color: #FFF;    
}

check this fiddle to see the example: http://jsfiddle.net/victorrseloy/mHLea/

the element name selector is stronger than class name, so your rule for 'a' elements will overwrite the '.homebutton' rule.

You can easily fix this, you need to add the 'a' element to your rule selector, so replace '.homebutton' with 'a.homebutton' in your css.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM