I am trying to create some a links using css
this is my css code:-
#footer-links a:link {
font-size: 12px;
color: #ffffff;
font-weight: normal;
}
#footer-links a:hover {
font-size: 12px;
color: #73de52;
font-weight: normal;
}
here is how i am calling it:-
|<span id="filter-links">Privacy Policy</span>|<span id="filter-links">Terms and Conditions</span>|
the first link works fine. It has white text with a green hover. But the second link reverts to blue text with green hover.
What am I missing?
Use Class selector instead of Id, as Id is a unique selector and always effects over the first element having that Id.
Thanks
.filter-links a:link {
font-size: 12px;
color: #262;
font-weight: normal;
}
.filter-links a:hover {
font-size: 12px;
color: #73de52;
font-weight: normal;
}
<span class="filter-links">Privacy Policy</span>|<span class="filter-links">Terms and Conditions</span>
I dont know if you making a mistake here, because your ID definition is filter-links instead of footer-links which you are using in your CSS. Check my snippet below for the correct one.
#filter-links a {
font-size: 12px;
color: #ffffff;
font-weight: normal;
}
#filter-links a:hover {
font-size: 12px;
color: #73de52;
font-weight: normal;
}
<span id="filter-links">
Privacy Policy
</span>
|
<span id="filter-links">
Terms and Conditions
</span>
Hopefully this do the job for you!
Related
I'm having one very difficult time getting :link and :visited to work on my links. I have been searching online for literally hours and read over 20 different instances of the same problem. Bizarrely enough, :hover and :active are working. What is going on?
Here's the code lines in my stylesheet:
H1 { text-align: center; width:1000px; font-size: 30pt; font-weight: bold; }
a.artlinks:link {color:#40C0FF; text-decoration: none; font-family: Cambria, Arial; }
a.artlinks:visited { color:#FF00FF; text-decoration: none; font-family: Cambria, Arial; }
a.artlinks:hover {color:#98D7F6; text-decoration: none; font-family: Cambria, Arial; }
a.artlinks:active {color:#FF0000; text-decoration: none; font-family: Cambria, Arial; }
and when I call it in my .html the code is:
<h1>Hello World!</h1>
Does anyone have a solution and also, a more efficient way to give the common a.artlinks parameters simultaneously? Thanks
Your code needs a bit of a tidy up, but this is how I would do it (edit I removed the width property from the h1 for demonstration purposes).
H1 {
text-align: center;
font-size: 30pt;
font-weight: bold;
}
a.artlinks {
text-decoration: none;
font-family: Cambria, Arial;
color:#40C0FF;
}
a.artlinks:visited {
color:#FF00FF;
}
a.artlinks:hover {
color:#98D7F6;
}
a.artlinks:active {
color:#FF0000;
}
See this jsfiddle: http://jsfiddle.net/lharby/zkb8thck/
As the a class has the same properties, you can define those once in a.artlinks (font-family, text-decoration). The other elements that are unique can then be defined for :hover, :active etc.
I have link CSS define as:
A
{
color: #315393; font-family: verdana; font-weight: 500; text-decoration:underline; font-size: 10px;
}
A:Hover
{
color: #999999; font-family: verdana; font-weight: 500; text-decoration:none; font-size: 10px;
}
However, there are a couple cases where I want a link to act like a button and for that I use bootstrap and give them the class of "btn btn-primary", but since they are still links it seems they are still using the above CSS. How can I exclude the link behavior CSS from these and is there a way to do it in-line to the link?
You can use :not pseudo-class to exclude certain elements from the matched selector:
a:not(.btn.btn-primary) {
color: #315393;
font-family: verdana;
font-weight: 500;
text-decoration:underline;
font-size: 10px;
}
a:not(.btn.btn-primary):hover {
color: #315393;
font-family: verdana;
font-weight: 500;
text-decoration:underline;
font-size: 10px;
}
My CSS has the following code for links for the whole website:
#mainpanecontent A:link {
FONT-WEIGHT: bold; COLOR: #6a0a0a; TEXT-DECORATION: none
}
I want to change a header that is also a link to be a different color using the code below but it doesn't enforce it. My code is inside a div that uses the "mainpanecontent" :
Header code
.contact
{
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
font-weight: bold;
padding-left: 50px;
background-position: 25px 14px;
padding-top: 13px;
}
.contact a:link, .contact a:visited
{
color: #1F507F;
}
.contact a:hover
{
color: #1F507F;
}
.contact a:active
{
color: #1F507F;
}
#mainpanecontent A:link has a higher specificity than any of your .contact a:somethings. The best way to solve this is probably to give your header an ID and use that. If you can’t, and it’s only in #maincontent, #maincontent will suffice, even if it’s not entirely appropriate. (Depends on the situation.)
#mainpanecontent .contact a:link {
color: #1f507f;
}
Also, just drop the :link, especially if you’re going to specify the same thing for all of them. (The only consideration there, <a name>, isn’t used these days.)
CSS has a system of priority for handling what gets what tags :: Give this a read
Here is a simple rewrite of your code that should work :)
Everything higher on the list should overwrite things lower of the list of the same type
.contact a:active
{
color: #1F507F;
}
.contact a:hover
{
color: #1F507F;
}
.contact a:link, .contact a:visited
{
color: #1F507F;
}
.contact
{
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
font-weight: bold;
padding-left: 50px;
background-position: 25px 14px;
padding-top: 13px;
}
CSS Rules are sometimes not enforced due to how explicit the previous rule was, in the rule you list above it references an ID, which is more explicit than a class.
The other issue of course can be that your "overrides" are defined BEFORE the other rule, therefore they are overwritten.
In the first case you can use !important to force the override of the rule.
e.g.
.contact
{
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
font-weight: bold;
padding-left: 50px;
background-position: 25px 14px;
padding-top: 13px;
}
.contact a {
color: #1F507F !important;
}
Note I removed the other rules, because you are only setting the link color to the same color in each case, so there's no need to define the pseudo-classes :hover, :active etc. with the same constant.
Hi thanks for reading my first question here at SO.
I'm the admin for http://www.theacoutlet.com and I'm adding some content pages. I took one element from the middle nav. bar ("FIND PRODUCTS") and made it a dropdown via CSS on hover.
The CSS (below) has been validated.
The problem is this sub-menu now displays three different ways in Firefox, IE, and Chrome. It does not appear to me to be very complex and I am stumped. It does not display at all in IE, and of course most of our customers use IE.
IE: Submenu does not display at all on hover.
Firefox: Submenu displays, with a wierd list item bullet (not in the HTML!) on top, and the menu appears over the original "FIND PRODUCTS" text.
Chrome: Submenu displays perfectly, only problem is it disappears quite easily when you try to hover over new items... requires extremely fast/precise mouse movements to keep menu from disappearing.
Code is below. Thanks for reading and appreciate your help!
HTML:
<div class="menisell2">
FIND PRODUCTS <img src="images/de_26.jpg" width="1" height="22" border="0" align="middle">
<span class="menisell2content">
<br>SEARCH<br><br>
COOLING<br><br>
HEAT PUMP<br><br>
DUAL FUEL<br><br>
GAS HEAT<br><br>
MINI SPLITS<br><br>
PACKAGE UNITS<br><br>
</span>
</div>
CSS:
.menisell2, .menisell2 a:visited {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FFFFFF;
text-decoration: none;
font-weight: bold;
display: inline;
position:relative;
}
.menisell2 a:visited {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FFFFFF;
text-decoration: none;
font-weight: bold;
}
.menisell2content a:visited {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FFFFFF;
text-decoration: none;
font-weight: bold;
}
.menisell2:hover {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #CE252C;
text-decoration: none;
}
.menisell2 a {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #FFFFFF;
text-decoration: none;
}
.menisell2content a {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #FFFFFF;
text-decoration: none;
background-color: #4682B4;
}
.menisell2content a:hover {
color: #CE252C;
}
.menisell2:hover .menisell2content{
visibility:visible;
}
.menisell2content{
visibility:hidden;
position:absolute;
width:100%;
display:list-item;
font-size: 12px;
color: #FFFFFF;
background-color: #4682B4;
}
I'm working on a page where I show an image and then have text at the bottom that's a link to a specific page.
By default the link is colored gray, but I want to override that and have the text picking up the h3 style.
Here's the CSS:
h3{
color: #a60000;
font-size: 20px;
font-weight: normal;
font-style: normal;
font-family: mpluslight;
}
a {
color: #CCC;
font-weight: normal;
}
Here's the HTML:
<h3>Personal Training</h3>
I tried by changing the h3 values to '!important' but that didn't work.
I'm trying to avoid using inline CSS. Trying to keep my code as clean as possible.
Any ideas?
You will need to do this:
h3 a { color: #a60000; }
... or possibly this:
h3 a { color: inherit; }