i am trying to fix a color of my TEXT color, its just WHITE so same color as background, dispite the fact its color is set for :#1a6eb6 and its set for same value in #submenu ul li .text I am prettz lost in it, can somebody help me with it?
My HTML:
<div class="submenu">
<ul>
<li><span class="text">DISKUSNÍ FÓRUM </span><span class="horizontal-arrow"></span><span class="vertical-arrow"></span></li>
<li><span class="text">KOMENTÁŘE </span><span class="horizontal-arrow"></span><span class="vertical-arrow"></span></li>
<li><span class="text">ZÁZNAM CHATU </span><span class="horizontal-arrow"></span><span class="vertical-arrow"></span></li>
<li><span class="text">UŽÍVATELÉ</span><span class="horizontal-arrow"></span><span class="vertical-arrow"></span></li>
</ul>
</div>
My CSS:
.submenu{
color: #1a6eb6;
display: inline-block;
height: 50px;
width:780px;
}
.submenu ul {
margin-left: 20px;
padding-left: 0px;
}
.submenu ul li{
list-style-position: inside; /* Bodka v novom riadku vo vnutry */
list-style-type: none; /* bez bodky */
background-image: url("images/shop_menu_bg.png");
background-repeat: repeat-x;
height: 38px;
width: 187px;
display: inline-block;
color: #1a6eb6;
}
.submenu ul li:hover {
background-image: url("images/shop_menu_bg_hover.png");
width: 187px;
height: 38px;
}
.submenu ul li .text{
color: #1a6eb6;
display: inline-block; /* aby sa dala rovnomerne posunut sipka a nie podla dlzky textu*/
height: 31px;
width:115px;
line-height: 28px;
margin-left: 5px;
}
.submenu ul li .horizontal-arrow{
background-image: url("images/horizontal_arrow.png");
background-repeat: repeat-x;
display: inline-block;
height: 19px;
width: 14px;
margin: 0px 0px 0px 45px;
vertical-align: middle;
}
.submenu ul li:hover .horizontal-arrow{
display:none;
}
.submenu ul li .vertical-arrow{
background-image: url("images/vertical_arrow.png");
background-repeat: repeat-x;
display:none;
height: 12px;
width: 19px;
margin: 0px 0px 0px 45px;
}
.submenu ul li:hover .vertical-arrow{
display: inline-block;
}
Live Preview can be find on: http://funedit.com/andurit/new/
Try adding the color to .submenu ul li .text a
.submenu ul li .text a{
color: #1a6eb6;
}
Font color was not changing because your styles.css had the below style which was overriding the color you specified to .submenu ul li .text
li a:link {
color: #f7f7f7;
}
You need to set the color of the <a> tag because that tag has color white.
something like:
.submenu ul li a{
color: #1a6eb6;
}
Many popular user agent stylesheets include a rule that selects a and sets its color:
a:-webkit-any-link {
color: -webkit-link;
text-decoration: underline;
cursor: auto;
}
This is sort of a blue-ish color. Moreover, your style.css has:
li a:link {
color: #f7f7f7;
font-weight: bold;
text-decoration: none;
}
This overrides the UA stylesheet and is why the link appears white. You need to actually select the a with your rule:
.submenu a:link {
color: #1a6eb6;
}
The :link part is necessary because of the specificity of the li a:link selector. You could also do .submenu li a or some other more specific selector.
if you just want to change the color of your text, you probably should use the "a" element like this:
#submenu ul li a{
//your code
}
Change css line 183 for element to
li a:visited
{
color: #1a6eb6;
}
Or you could create a new css selector like
.submenu ul li a
{
color: #1a6eb6;
}
style.css line 183 - you have li a:visited {color:#f7f7f7};
style.cc line 173 - you have li a:link {color:#f7f7f7;}
This is I got from chrome console. check these lines in your css file and take out the color:#f7f7f7
you can also use the !important rule in css to make sure that rule overwrites any other rule.
What does !important in CSS mean?
.submenu{
color: #1a6eb6 !important;;
}
Related
I put a link in the image which leads back to the home page; however, I have my nav menu set up so they turn red with hovering and somehow it's making a red block behind my image when I hover over it. I'm using HTML5 and CSS3
HTML5
<header class ="main-header">
<a href="index.html">
<img src="Images/image.png" alt="image logo"></a>
<nav><ul>
<li class="active">HOME</li>
<li>NEWS</li>
<li>LOCATION</li>
</ul></nav>
</header>
CSS3
/* Define Hyperlink Info */
a {
color: #FFFFFF;
font-weight: bold;
text-decoration: none;
}
a:link, a:visited{
color: #FFFFFF;
text-decoration: none;
}
a:hover, a:active {
background-color: #C71F0E;
color: #FFFFFF;
text-decoration: none;
}
/* Defines navigation menu */
.main-header nav {
background-color: #354175;
height: 40px;
}
.main-header nav ul {
list-style: none;
margin: auto;
}
.main-header nav ul li {
display: inline;
float: left;
}
.main-header nav li a:hover, .main-header nav li.active {
background-color: #C71F0E;
color: #FFFFFF;
text-shadow: none;
}
.main-header nav ul li a {
border-radius: 15px;
color: #FFFFFF;
display: block;
height: 20px;
padding: 10px 25px;
}
If you look at the a:link, a:visited line, you'll notice that this targets ALL links, even your image link.
To do away with this, try giving your first link a class (like "logo"), and write specific styles for it after the a:link, a:visited line.
My CSS code is not allowing the sub nav to stay open allowing the user to be able to select an option. What am i missing? I believe it is something to do with the last CSS style. As it is now it shows when you mouse over. As soon as you start to move your mouse down to select an option it disappears.
Please could someone help:
HTML
<div id="navigation_bar">
<ul>
<li id="">Home</font></li>
<li>Beauty Treatments
<ul>
<li>Manicure & Pedicure</li>
<li>Gel Manicure & Pedicure</li>
<li>Waxing</li>
<li>Facials</li>
<li>Make-up</li>
<li>Eye Treatments</li>
</ul>
</div>
CSS
#navigation_bar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#navigation_bar ul li {
float: left;
}
#navigation_bar ul li a {
display: block;
padding: 0 20px 0 20px;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #222;
font-weight: bold;
text-decoration: none;
line-height: 36px;
border: none;
}
#navigation_bar ul li a:hover {
border: none;
color: #ffffff;
background-image: url(Images/mouse_over_background.gif);
z-index: 1;
}
#navigation_bar ul li ul li {
float: none;
z-index: 2;
}
#navigation_bar ul li ul {
position: absolute;
display: none;
}
#navigation_bar ul li:hover ul {
display: block;
}
Simple bug
Your error:
CSS:
#navigation_bar ul li a:hover{
border:none;
color:#ffffff;
background-image:url(Images/mouse_over_background.gif);
z-index:1;
}
What it should be:
#navigation_bar ul li a:hover{
border:none;
color:black;
background-image:url(Images/mouse_over_background.gif);
z-index:1;
}
I have had a look at the Fiddle and corrected the missing </li> tag. Now the code works the way im seeing not that it is working fine in the fiddle. I have updated the fiddle: http://jsfiddle.net/CtPcA/1. The background image is a purple block say on hover and the text then changes to white
I know this question has been asked so many times before. But I just can't find the right trick for my code. I want a different color for my active list item in the navigation bar. Obviously. Silly little thing. I know. But please try to help.
Here's my HTML code:
<div id="container">
<ul id="nav">
<li class="active">Home</li>
<li>Teaching Assistants</li>
<li>Course Info</li>
<li>Time Table</li>
</ul>
</div>
and Here's the CSS file:
#container {
position: relative;
top: -2em;
z-index: 2;
width: 1200px;
margin: auto auto;
}
#nav {
position: relative;
float: left;
margin-left: 400px;
}
#nav li {
list-style: none;
float: left;
border-right: 1px solid #afc4cc;
}
#nav li a {
position: relative;
z-index: 2;
float: left;
padding: 5px 45px;
font-size: 15px;
font-weight: bold;
font-family: helvetica, arial, sans-serif;
text-decoration: none;
color: #39aea8;
}
ul, li {
margin: 0;
padding: 0;
}
ul#nav li a:link,ul#nav li a:visited {
color: #39aea8;
text-decoration: none;
}
ul#nav li a:hover,ul#nav li a:active {
color: #f4ba51;
text-decoration: none;
}
There's something wrong with your CSS code. Just replace this:
ul#nav li a:hover,ul#nav li a:active{
}
with this:
ul#nav li a:hover,ul#nav li.active a{
// here styling
}
and you are good to go. You just made a mistake while calling the active class in CSS.
ul#nav li.active a { color: #f4ba51 ; }
I'd like to make a black navigation bar for my website, and when you hover over the first link it goes orange, the second link it goes green, etc. I know how to change colour on hover but don't know how to make each link different.
I figure its something to do with giving ids to each li tag?
<div id="navbar">
<ul>
<li id="link1">1</li>
<li id="link2">2</li>
<li id="link3">3</li>
</ul>
</div>
But then how do I create different styles for each of these ids in the css file?
Below is what I tried
#navbar ul li a {
text-decoration: none;
padding-top: 25px;
padding-bottom: 25px;
padding-left: 30px;
padding-right: 30px;
color: #ffffff;
background-color: #000000;
}
#navbar ul li #link1 a:hover {
color: #ffffff;
background-color: #C62222;
padding-top:15px;
padding-bottom:15px;
}
#navbar ul li #link2 a:hover {
color: #ffffff;
background-color: #28C622;
padding-top:15px;
padding-bottom:15px;
}
Help much appreciated!
What you're doing is on the right track, but don't repeat the CSS over and over:
#navbar ul li a:hover {
color: #ffffff;
padding-top:15px;
padding-bottom:15px;
}
#navbar ul #link1 a:hover {
background-color: #C62222;
}
#navbar ul #link2 a:hover {
background-color: #28C622;
}
As others have noted, you also need to either remove the space between the li and your id, or just remove the li entirely (since there is only one link1, you don't necessarily need to tell the browser that it is an li).
Additionally, if you want, you can (and probably should) simply those selectors all the way down to #link1 a:hover and #link2 a:hover. It's more of a stylistic choice, but it helps to keep your code clean.
You have a bad selector. The li is superfluous.
#navbar #link1 a:hover {
color: #ffffff;
background-color: #C62222;
padding-top:15px;
padding-bottom:15px;
}
You need to remove the space between li and #link1:
#navbar ul li#link1 a:hover
You could further optimize your CSS like this:
#navbar a {
text-decoration: none;
padding: 25px 30px; /* shortcode for top/bottom - left/right */
color: #ffffff;
background-color: #000000;
}
#navbar a:hover { /* common hover styles */
color: #ffffff;
padding:15px 30px;
}
#link1 a:hover { /* individual hover styles */
background-color: #C62222;
}
#link2 a:hover { /* individual hover styles */
background-color: #28C622;
}
remove the space between li and #link2.
#navbar ul li#link1 a:hover {
color: #ffffff;
background-color: #C62222;
padding-top:15px;
padding-bottom:15px;
}
#navbar ul li#link2 a:hover {
color: #ffffff;
background-color: #28C622;
padding-top:15px;
padding-bottom:15px;
}
You were close, but the space between li and #linkX is causing problems. These are not two separate elements, so they should be combined. One possible method is:
#navbar ul li#link1 a:hover {
....
Alternately, you can use:
#navbar ul #link1 a:hover {
....
You may wish to combine the duplicated styles into a single directive:
#navbar ul li a:hover {
color: #ffffff;
padding-top:15px;
padding-bottom:15px;
}
Then use only the changed style as needed:
#link1 a:hover {
background-color: #C62222;
}
This is my little CSS style:
#languages_menu
{
background: url('/images/langs.png') repeat-y;
bottom: 40px;
font-size: 0.9em;
right: 10px;
position: absolute;
width: 90px;
}
#languages_menu ul, #languages_menu ul li
{
list-style: none;
}
#languages_menu ul li a
{
cursor: pointer;
display: block;
line-height: 22px;
margin-left: 10px;
text-decoration: none;
width: 80px;
}
#languages_menu ul li a:hover
{
background-color: #AEBDD2;
color: #F00;
}
#languages_menu ul li a span.flag
{
float: left;
margin: 3px 5px 0 3px;
}
And this is my HTML code (copied from Developer Toolbar, so don't worry, it's valid):
<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" -->
...
<DIV id=languages_menu><DIV class=topimg></DIV>
<DIV>
<UL>
<LI><A class=en><SPAN class=flag></SPAN><SPAN class=name>English</SPAN></A></LI>
<LI><A class=fr><SPAN class=flag></SPAN><SPAN class=name>Français</SPAN></A></LI>
...
</UL>
</DIV>
</DIV>
In IE8, IE8Compatibility and IE9, and in every other browser, :HOVER is working like a charm. But if I switch to IE7 or lesser, the anchor is not changing anymore on mouse over.
The worst thing is that I have other similar codes on the same page and they are still working after I switch to IE7, like the following one:
#navigation
{
height: 22px;
position: relative;
width: 100%;
}
#navigation ul
{
float: left;
left: 50%;
}
#navigation ul, #navigation ul li
{
float: left;
list-style: none;
position: relative;
}
#navigation ul li
{
right: 50%;
}
#navigation ul li a
{
color: #889DBF;
display: block;
line-height: 22px;
padding-left: 20px;
text-decoration: none;
}
#navigation ul li a b
{
display: block;
padding-right: 21px;
}
#navigation ul li.current a, #navigation ul li a:hover
{
background: url('/images/navigation-left.png') no-repeat;
color: #111B35;
}
#navigation ul li.current a b, #navigation ul li a:hover b
{
background: url('/images/navigation-right.png') no-repeat 100% 0;
color: #111B35;
}
<DIV id=navigation>
<UL>
<LI class=current><B id=text_menu_login>Accedi</B></LI>
<LI><B id=text_menu_register>Registrati</B></LI>
...
</UL>
</DIV>
Anyone knows why this is happening and how to fix it?
[EDIT]
I just found a fix for this bug.
If i replace:
#languages_menu ul li a:hover
With:
#languages_menu ul li:hover a
The menu works great even with IE lesser than 8. But I don't think it's a good solution for cross-browser compatibility because :hover pseudo-class can not be used in IE lesser than 7.
MANY MANY THANKS ERIC!
you need to add href to your anchor, a:hover is not picked up by IE7 otherwise:
<A class=en href="#">
another trick is to add empty rule in your css:
#languages_menu ul li a:hover {
/* all your hover rules go here */
}
#languages_menu ul li:hover a {
/* keep this empty, triggers a:hover on IE7 */
}
Add a default background-color to your non-hovered link (just use white).