Forum Moderators: not2easy
When it comes to creating the beveling effect, what is the best way to achieve this? Right now I am using the border outset attribute and it looks great in IE. Just checked it out in Opera 6.05 and it does not look as I expected. I am familiar with all of the border attributes and was wondering which one, or combination thereof would be the best way to create the beveled effect. My current css looks like this...
#menu{
position:absolute;
left:6px;
top:118px;
width:130px;
}
#menu a{
display:block;
text-decoration:none;
padding:2px;
margin-bottom:0px;
border:1px outset;
color:#efefef;
background:#369;
font-size:12px;
text-align:left;
line-height:14px;
width:100%;
}
#menu a:hover{
border:1px outset;
color:#369;
background:#f9d543;
}
#menu a:active{
border:1px outset;
color:#369;
background:#efefef;
}
Here's something I've been using...
a.button {
padding: 2px 10px 3px 10px;
border: 2px outset #5AA0B8;
background: #046;
color: #FFF;
text-decoration: none;
height: 19px;
vertical-align: bottom;
}
a.button:active, a.button:focus, a.button:hover {
border: 2px inset #5aa0b8;
vertical-align: middle;
background: #046;
color: #5AA0B8;
text-decoration: none;
}
I've been toggling between using ridge as opposed to outset. When I use the ridge attribute, Opera displays them a little closer to what I expected. It appears that the ridge and outset are the same in IE when using a 1px border. I tried the 2px for a more beveled effect and it was just a little too much for the design I'm working with. I want to keep them tight and just get that slight beveling effect.
It looks great in IE. As soon as time permits, I'm going to get these to work in Opera and Moz. And please, don't even bring up NN4.x in this topic, that browser is now dead!
Play around with specific border-top/border-left (etc.) colors. Then, just add a little thingy for IE with conditional comments.
In general, other browsers make the highlight lighter than IE does... Even if you specify the color. Why? Because they add highlight to the color, which IE doesn't...
Here is the code I've come up with so far. This menu sits against a dark blue back drop, hence the border colors to acheive a beveled effect.
border-top:1px solid #ccc;
border-left:1px solid #ccc;
border-right:1px solid #808080;
border-bottom:1px solid #000; Works like a charm. Now, I'm sure someone is going to show me a more optimized version of this and I'll be waiting. ;)
P.S. Inset and Outset produce different results across the browsers. As a matter of fact, those two only worked in IE. Setting the properties of all four borders is the only way to produce similar results cross browser.
The W3C CSS Validator gave me warnings about redefining my border attributes when using the shorthand version.
Warnings are not ERRORS.
Think of them as "kindly Old Mother Validator" asking you if you remembered to brush your teeth, wash behind your ears, and... as you head out the door, remembered to bring your rubbers. (What?--It looks like rain! Sheesh! What were YOU thinking?)
"Warnings" are just that... kindly, but at times stern sounding, even a bit annoying, reminders to be sure you know what you are doing, and why you are doing it.
Use the shorthand property.
- papabaer
#menu :link, #menu :link:active, #menu :link:hover {
border: 2px outset gray;
padding: 1px 6px 2px 5px;
}
#menu :link:hover:active {
border: 2px inset gray;
padding: 2px 5px 1px 6px;
}
<div id="menu"><a href="#a">foo</a><a href="#b">bar</a></div>
Papabaer, I just don't like the warnings. I like to see that no errors, no warnings come up when validating. Since I stopped support for NN4.x, I don't see them anymore because I am not using the @import statement and getting a long list of warnings about redefining everything.
As soon as I added the four border attributes, I was able to acheive the effect of inset or outset without using those attributes.
a:link - Specify one set of borders to create the outset look.
a:hover - Specify another set of borders to create the inset look.
P.S. IE was rendering them just as I thought it would. I did not see any problems with the top and bottom borders when I was using just this...
border:1px solid outset;
#menu{
position:absolute;
left:9px;
top:114px;width:116px;
}
#menu a{
display:block;
font-size:11px;
color:#efefef;
background:#369;
text-decoration:none;
padding:2px;
margin:0px;
border-top:1px solid #ccc;
border-left:1px solid #ccc;
border-right:1px solid #808080;
border-bottom:1px solid #000;
width:116px;
line-height:15px;
}
#menu a:hover{
color:#369;
background:#efefef;
}
#menu a:active{
color:#369;
background:#f9d543;
} I then added a special p class that contains the border code and created headers to separate the beveled buttons into categories.
p.menuhead{
border-top:1px solid #ccc;
border-left:1px solid #ccc;
border-right:1px solid #808080;
border-bottom:1px solid #000;
margin:0px;
padding:1px 2px 3px 2px;
font-size:12px;
font-variant:small-caps;
font-weight:bold;
color:#369;
background:#f9d543;
width:116px;
line-height:15px;
cursor:help;
}
For example:
#homepage a#home {styles}
#about a#about {styles}
So if a visitor was at the homepage, the homepage button would be "pressed." And if the visitor would be on the about page, the about button would be "pressed."
No need for multiple navigation files or scripting.
If interested, I have a <snip>
Cheers,
KT
[edited by: Nick_W at 11:25 am (utc) on May 16, 2003]
[edit reason] no urls please [/edit]
I have a left nav menu. That menu is being controlled using the code above. That left nav menu is also an include. Do I assign the ids to each a href? And then place the appropriate id in the body tag for that page?
<div id="menu">
<a id="cfp" href...></a>
<a id="cmt" href...></a>
</div>
And then in my css...
#menu a#cfp {color:#ccc;background:#369;}
#menu a#cmt {color:#ccc;background:#369;}
I'm still learning this css stuff! ;)
<edit>Changed sequence of css</edit>
[edited by: pageoneresults at 3:17 am (utc) on May 16, 2003]
"Do I assign the ids to each a href?"
Yes, you would need unique id's for each button (a href) you want to have the active state applied to.
"And then place the appropriate id in the body tag for that page?"
No. Each page that corresponds to a button that you want to be affected would have its own id. For example, let's assume that your "cfp" link is the link for your homepage. Here's what you could have:
HTML of homepage document:
<body id="homepage"> <-- you assign an id for the page
CSS:
#homepage a#cfp {styles} <-- then you do something like this
This would work in an included file as well since each link will have its own unique id and each body tag of a web page, you want affected, would have its own unique id.
It may sound like a lot of code, but if the button active effect is the same across multiple links, you can list the selectors comma-like (what's the proper term?).
Example:
#homepage a#cfp, #about a#cmt {styles}
If you haven't already, feel free to download the example files (the link in my previous post) and hack them.
hth,
KT
P.S. Add width:100%; to your a elements and the entire <div> will become active instead of just the text link.
P.S.S. I haven't been this excited since I removed my first <font> tag years ago and replaced it with css!
#index a#index, #cfp a#cfp
Since I've never really worked with ids, I did not realize that your body id and a href id cannot be one in the same. So, I just added a "b" in front of the body ids like this...
#bindex a#index, #bcfp a#bcfp
Using two ids with the same name is apparently not valid html. Found that out after I set everything up and decided to check my html validation. It failed until I made sure the ids were unique.
Okay, you css fans are really gonna love this one. I've been working on a navigation menu built purely in css that to many may look like a graphical button structure. My goal this year is to strip as many graphics that I possibly can from future design projects and use pure css. Here is the menu code, this is for a stacked left hand vertical navigation menu...
#menu{
position:absolute;
left:9px;top:114px;
width:116px;
}
#menu a{
display:block;
font-size:11px;
color:#efefef;
background:#369;
text-decoration:none;
padding:2px;
margin:0px;
border-top:1px solid #ccc;
border-left:1px solid #ccc;
border-right:1px solid #808080;
border-bottom:1px solid #000;
width:116px;
line-height:15px;
}
#menu a:hover{
color:#369;
background:#ccc;
}
#menu a:active{
color:#369;
background:#f9d543;
}
You would of course adjust the attributes to meet your requirements. Now, here comes the spice...
#bindex a#index, #bcfp a#cfp, #bcmt a#cmt, #bcontact a#contact, #bemail a#email{
color:#369;
background:#efefef;
}
The code directly above is what controls the on page state of the button depending on which page you are on (compliments of one of our newest members keimano tokoyami [webmasterworld.com]). These are what is referred to as ids. You have to assign a unique id to each link so that you can control the active state.
Then, depending on which page you are on, you assign the unique id to the body tag like this...
<body id="bindex">
That body id tells the browser what the state of the active button should look like when the visitor is on that page.
Note: You must assign a unique id for the body and then another for the link. You cannot have two ids on the same page that are named the same, it is not valid html.
The left hand menu is set up as an include and the link in the include looks like this...
<a title="Home Page" id="index" href="/index.asp">Home Page</a>
Now, this is not for the casual css user who fiddles every now and then with css. This took me a while to learn and figure it all out. Now that I have, there is no turning back.
Many thanks go to Nick_W, papabaer, DrDoc, Birdman, drbrain and keimano tokoyami who provided the on page active state css solution for the buttons.
Ah, this css is so much fun!
The next thing to do, if you decide it's worth it, is to make the list of links more semantic by using lists (ordered or unordered).
Rather than using a div#nav, you could have ul#nav, or something, which is what I use.
Example:
ul#navi {border: 1px solid;list-style-type: none;margin: 0 175px 15px 165px;padding: 0;height: 20px;
voice-family: "\"}\"";voice-family:inherit;height: 18px;}html>body ul#navi {height: 18px;}
ul#navi li {display: inline;font-size: 80%;margin: 0;padding: 0;}
I believe if you set the anchors to "display: block;" and specify their size, you have no need to specify "width: 100%;". Could doctype also be a factor? I use XHTML 1.0 Trans, ul#nav, and block and size my anchors and the entire "button" area is clickable. No need for "width: 100%;".
To ensure that the size of each button is the same on almost all browsers (that supports this stuff), I incorporate the "box model hack" for IE 5. Depending on one's design and/or needs, this may be negligible.
Example:
ul#navi a {display: block;font-weight: bold;text-decoration: none;}
li#nHome a, li#nAbout a {border: 1px solid;margin: 0;padding: 2px 1px 2px 1px;text-align: center;position: absolute;}
li#nHome a {width: 50px;top: 133px;left: 166px;}
li#nAbout a {width: 50px;top: 133px;left: 216px;
voice-family: "\"}\"";voice-family:inherit;left: 220px;}html>body li#nAbout a {left: 220px;}
Another challenge for the buttons is to list them length-wise rather than stacked from top to bottom. I do this with "position: absolute;" (along with "top:" and "left:", etc.) and all browsers except Opera display this fine. Why? Because I absolute position the anchors but not the list container (or list items). And since I applied a style to the container (background and 1px border), you can tell where the lists/buttons are "suppose" actually be. Normally I would use the "box model hack" to fix this but since NN 7 displays it fine as-is, it gets screwy with the "hack" applied.
Possible solutions:
1. Apply absolute position to the list items and not the anchors/buttons. But I doubt it would correct the list container.
2. Float could work, but I'm trying not to use it. If anyone tries this, please let me know if comes out alright.
More fun play! :D
"No need for 'width: 100%;'."
I didn't need the 100% set for width in my "side-by-side" list of buttons because it was set explicitly (in pixels). I'm sure if one were to do that in the stacked order, then not needing "width: 100%;" would still remain true.
As for the accessibility consideration, I made that sacrifice for my current layout (side-by-side), however I don't see it being to difficult to modify with what pageoneresults is doing.
Thanks for that reminder papabaer. :D
I've been using beveled menu buttons in one form or another for well over a year and a half, but it's only been since last November that I took them fluid. Em is good!
I love it! Using Internet Explorer, I can select the LARGEST text size, hit F11 for full screen and watch as the menu scales accordingly. From "SMALL SCREEN RENDERING" to full screen, large text, I have it covered. It's a nice feeling too... :D
Nice to have you with us!
- papabaer
p.s. the above statement does not endorse the use of Internet Explorer. ;)
I've been experimenting with adding background images to the link, visited, hover and active states. Did some reading at various cutting edge css sites and come to realize that you can literally recreate a graphic button navigation structure using pure css. No more javascript!
Example...
}
#menu a:hover{
color:#369;
background:#fff repeat fixed url('/images/tile.jpg');
border-top:1px solid #000;
border-left:1px solid #808080;
border-right:1px solid #ccc;
border-bottom:1px solid #ccc;
}
I'm using a background now that tiles seamlessly. The button sits against the same background. It's a really nice effect that I thought could only be achieved using javascript.
You can really get advance with CSS background images, but you need to consider your original purpose. If it is reduced load times and fast rendering speeds, tiled or multiple application images, may be the best compromise.
Note: url('/images/tile.jpg') <--- IE5 MAC gets confused by the single quotation marks. It computes them as part of the actual string. IE5 MAC will fill your logs with 404's because of this.
The quotes are optional... doubles, no problems, single qoutes, IE5 Mac will stumble. No qoutes, all is well.
The quotes are optional... doubles, no problems, single qoutes, IE5 Mac will stumble. No qoutes, all is well.
Thanks papabaer, that's a new one. Actually, I did test this in IE5 on the Mac and did not see any visible problems. Haven't looked at the 404s yet on that site, it's new.
Well, I'll now be spending my next living moments updating style sheets. It never fails, whenever you or Nick_W or one of the other css gurus steps in, I don't get any real work done! ;)
I removed the single quotes and no more 404's.
This IE Mac anomaly also reared its ugly head for imported style sheets. I now will use the the @import rule to import global styles into a page or section specific style sheet.
If I used single quotes e.g. @import url('copy.css'); MAC IE5 would not import the style sheet. The 404's flagged it.
Okay, I think I figured this one out. I've tested in IE and Opera and it appears to be working as intended...
#menu{
position:absolute;
left:1px;
top:31px;
width:100%;
padding:5px 0px;
white-space:nowrap;
}
#menu a{
display:inline;
border-top:1px solid #ccc;
border-left:1px solid #ccc;
border-right:1px solid #808080;
border-bottom:1px solid #000;
font-size:11px;
color:#ccc;
background:#68849c;
text-decoration:none;
padding:3px 2px 3px 4px;
text-align:center;
}
#menu a:hover{
border-top:1px solid #000;
border-left:1px solid #666;
border-right:1px solid #ccc;
border-bottom:1px solid #ccc;
color:#fff;
background:#47748e url('/images/tile-blu-blu-grn.jpg') fixed;
}
#menu a:active{
color:#fff;
background:#47748e;
}
Note that I have my menu absolutely positioned from the top at 31px. This is because I have a <div> sitting above the navigation that runs 100% the width of the window and is 30px in height with a 1px top/bottom border. The code looks like this...
div.top{
position:absolute;
top:0px;
left:0px;
padding:0px;
margin:0px;
width:100%;
height:30px;
text-align:right;
white-space:nowrap;
color:#000;
background:#47748e;
border-top:1px solid;
border-bottom:1px solid;
z-index:1;
}
I've positioned the #menu exactly 1px below the top div (31px). This creates a nice shadow effect when merged with the border of the #menu a elements. I think it is the white-space:no-wrap; that may solve the problem discussed earlier.
Note: <a href's> must be on one line in your code...
<a href></a><a href></a><a href></a>
P.S. Tell me why I get a space when putting the <a href> on a line by itself in the code. No, there are no <br /> tags either.
<a href></a>
<a href></a>
<a href></a>