Forum Moderators: not2easy

Message Too Old, No Replies

Nav is picking up link settings

Rwd Css3 Html5

         

Lorel

6:37 pm on Aug 19, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have set up NAV for the top menu with blue letters and a dark blue background and that works fine.

However, when trying to format the links on the page (which has the dark blue of the NAV background) the links disappear in the NAV. Also there is a conflict with font sizes as they are both different (regular links are picking up Nav font size).

Big mess.

How do I prevent the NAV from picking up link settings and visa-versa? I know how to do this in pre CSS3 but then I'd have to name NAV as a class which seems redundatnt being as I'm trying to use CSS3. Here is the relevant code:

html {
/* base font size */
font-size: 16px; }

body {
margin: 0 0 10px 0;
padding:0;
font-family: Arial, Helvetica, Georgia, Sans-serif;
font-size: 100%; /* 16px*/
background: #fff;
color: #000; }


nav { text-align:center;
background-color: #336699; }
nav ul {
list-style: none;
margin: 0;
padding:0; }
nav ul li {
text-align: center;
display: inline-block;
position: relative;
font-size: 0.938em; } /*15px*/
nav ul li a {
padding: 0.313em 0.813em; /*5px 13px*/
color: #99CCFF;
text-decoration: none;
font-weight: bold;
display: block;
width: 8.750em; } /*140px*/
nav ul li a:hover {
color: #FFCC33;
font-size: 0.938em; } /*15px*/
nav ul ul {
display: none;
position: absolute;
top: 20px;
background-color: #336699;
z-index: 999; }
nav ul ul li {
min-width: 300px;
text-align:left;
font-size: 0.938em; } /*15px*/
nav ul ul li a {
min-width: 300px; }
nav ul li:hover > ul {
display: block; }
nav select {
display: none;
padding:0.625em; /*10px increases size of select tag */
font-size:1.250em; } /*20px increases font size in select tag */


a:link, a:visited {color: #336699;
font-weight: normal;
background: transparent;
text-decoration: none;
font-weight:normal;
font-size: 0.875em; } /*14px*/
a:hover, a:active {color:#FFCC33;
font-weight: normal;
background: transparent;
text-decoration: underline;
font-weight:normal;
font-size: 0.875em; } /*14px*/

Lorel

5:42 pm on Aug 22, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



PS. I commented out the regular links and Nav is still changing font sizes on hover. I don't have hover listed anywhere else in CSS. Both CSS and HTML validate.

Anyone have a solution for this?

not2easy

10:18 pm on Aug 22, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I believe the problem is that <nav> is an element like <p> (but without default variables) and its function is to contain navigation links, but it would be like assigning link properties to a <p> that contained links - they will look to the "a" element to determine the variables to use. If you visit the W3C site there is more definition: [w3.org...]

Lorel

10:53 pm on Aug 22, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@not2easy,

Thanks for that link. I understand how Nav is different from other links. However it didn't mention why the links should be changing font size from the main menu to the sub menu on hover. I completely removed the normal link settings so that can't be the problem. There must be another reason for the font size change.

I have HTML set at 16 px and nothing in the body and Nav set at 15px;

html {
/* base font size */
font-size: 16px; }

Could this be causing a problem?