
Originally Posted by
Grey
Do you mean like this ?
.navbar3 ul li { display: inline; }
.navbar3 ul li a {
text-decoration: none;
padding: .2em 1em;
border-style: outset;
border-color: #8DA5F1;
border-width: 3px;
color: #fff;
background-color: #6699CC;
}
.navbar3 ul li a.button:visited {
font-size: 14px;
font-weight: bold;
text-decoration: none;
color: #B4B4FB;
border-style: outset;
border-color: #8DA5F1;
border-width: 3px;
background-color: #FFFFCE;
}
.navbar3 ul li a:hover {
color: #000;
border-style: outset;
border-color: #F4F707;
border-width: 2px;
background-color: #FFCC33;
}
<div class="navbar3">
<ul>
<li><a href="#top"> Top of page</a><li></ul></div>
yes that will work but you can take it once step further.
if the only element in the navbar is a list you can set the unordered list element to the class to prevent the extraneous code, and also you can eliminate some of the extra styles above as they will be inherited by default...
Code:
<ul class="navbar3">
<li><a href="#top">Return to Top</a></li>
<li><a class="button" href="/path/to/file">Button Link</a></li>
<li><a href="/path/to/file">Link</a></li>
<li><a href="/path/to/file">Link</a></li>
</ul>
Code:
<style type="text/css">
ul.navbar3 {
background: #6699cc;
color: #ffffff;
font-size: 14pt;
}
ul.navbar3 li, ul.navbar3 li a {
display: inline;
color: inherit; /* necessary for the anchor tag */
text-decoration: none;
border: 3px outset #8DA5F1;
}
ul.navbar3 li {
padding: .2em 1em;
}
ul.navbar3 li a.button:link {
/* 'button class' default styles */
}
ul.navbar3 li a.button:link {
/* 'button class' visited (return to the page after a link has been clicked styles */
}
ul.navbar3 li a.button:hover {
/* 'button class' hover (mouse position is over link) styles */
}
ul.navbar3 li a.button:active {
/* 'button class' active (while the link is being clicked) styles */
}
ul.navbar3 li a:visited {
font-weight: bold;
color: #ffffce;
}
ul.navbar li a:hover {
background-color: #ffcc33;
color: #000;
border: 2px outset #f4f707;
}
What you were doing is not technically incorrect, there is just extra code in there that will clog up your webserver, hosting & bandwidth most notably.
Blizzard had the right idea and I am sure he knows what he was meaning, but I think it was a little bit ambiguous on how it was interpretted, so I will attempt to redefine what he was saying in different terms.
By default, any element will inherit (take on) the style of its parent element (the element it's wrapped in) unless otherwise declared explicitly. The anomoly to that is default browser styles, e.g. the achor <a> tag. By default it will have blue underlined styles regardless of what element it is enclosed in, unless the developer explicitly sets it differently.
Some "unwritten rules" to designing with CSS include trying to set as much of your default styles in the body <body> tag, some of the more commonly used styles are
margin: 1em;
padding: 1em;
margins and padding generally get abused because many people do not know the difference... margins are applied as a buffer outside of the element and padding is applied to the inside of the element.. this doesnt really make alot of sense when you first look at it, but take a look at http://www.htmldog.com/guides/cssbeginner/margins/ as they do alot better job than I could ever do.
Edit:
// had this in the middle of the background definition which could cause confusion...
width: 80%;
this again gets abused by people whom really do not develop for all browsers. this is obviously the width of the element that it is applied to, and again this should be done in percentages as much as possible to allow the browser to render accordingly, because each different rendering engine (what takes the code you give it and makes it visible on screen) will display slightly differently... most notably pixels... IE pixel rendering and most other browsers are different slightly, but it can make a big difference between a horizontal scroll bar and no horizontal scroll bar. so try to keep your widths in percentages... now if you have a minimum width required or a maximum there are different tags for those min-width max-width respectively... and these really would be the only place that you should use pixels to define widths... now on that note.. if you are attempting to be friendly to older screen resolutions (800x600) you cannot set the minimum width to 800px because that is the width of the whole screen, not what is viewable in the browser... 760px would be the width to set it at to be friendly for 800x600 resolutions.
background: #hexadecimal url('/path/to/image') repeat attachment position;
hexadecimal is the term used for html color codes 0-15 or (0-9 A-F) this is the perferred method because it allows for the most precise rendering of color to the page.
url('/path/to/image') pretty much self explanatory but the path may be declared a couple of ways.
absolute - this is the path of the entire url of the image http://www.domain.com/forums/images/example.gif
this is best for linking images from other domains (with permission of course)
relative - this is the path from the path the script is running
so if you were in the "forums" folder in the url above you would write the path as
images/example.gif this can become quite confusing because if you move a script(page) around you would then need to update all of the paths associated
absolute relative - this is a term I coined and its a combination of both. By starting the path of an image with a forward slash / the path of the image starts from the web document root (the domain as viewable on the web) so you would write the url list
/forums/images/example.gif in this method you only need to worry about the physical image file being moved, not the script (page) that is running the script because the path of the image will ALWAYS start at the end of the original domain declaration.
repeat whether or not the image will repeat values can be no-repeat, repeat, repeat-x (horizontal axis) repeat-y (vertical axis)
attachment - whether the image will stay where it is or scroll with the page. this is the css "watermark" ability. values can be fixed,scroll
position - relative to the element, where will the image be
top,bottom,center,left,right are all among the values.. you can have2 values 1 for vertical and 1 for horizontal
color: #hexadecimal
font-size: 14pt /* this should be the only place you explicitly set the font-size... all other elements should be given percentages so in the future if you wish to make a change you will only need to edit this 1 size and the rest of the site updates instantaneously and keeps the same proportions */
font-family: Arial, Helvetica, sans-serif;
this will be how the font appears on screen this is tricky because the user must have the font type file available so it is always good to declare 2 fonts you would like then the font type group the font comes from so that if the user has neither font type the page wont be entirely busted and the default group font the user has set up will be shown.
there are a number of other font types however these are the main two you will see declared for the entire page.
I know you are probably wondering why you are still reading, but the last thing I will yap about is an element within an element and different "states" of an anchor tag.
in my definition i stated
By default, any element will inherit (take on) the style of its parent element (the element it's wrapped in) unless otherwise declared explicitly.
and what i mean by that is if you had the set up
Code:
<div>
<p>TEXT <span>OTHER</span></p>
</div>
the TEXT contained in the paragraph tag will take on both the paragraph styles and the div styles... and the OTHER will take the span styles, paragraph styles, and div styles all accordingly, trumping (overwriting) styles that were given before.
I can explain that more if needed but I think thats a pretty good overview
the very last thing is the states of an anchor tag
ever tag has these different states, but until IE6 becomes obsolete much of the states will not be "accessible" to CSS solely... meaning you would need to use some javascript to achieve the same affect...
in my redoing of the menu I declared the anchor states in the LoVe HAte terms meaning
link (default)
visited (clicked)
hover (moused over)
active (being clicked on)
now there are other states, but we will not go into those... these follow the same rules as regular elements so you do not have to keep declaring text-decoration:none for every state if they are the same...
and the punch-line is.... only duplicate style properties to trump a previous definition... and remember that each element has its own browser defaults... those will always take affect unless you set otherwise
Bookmarks