ivar
Sep-03-2006, 04:30 AM
I've been looking at navbars for a while, trying to create one with rounded corners, without the need for images and photoshopping etc. All the ones i found on the net were okay, but had some sort of limitation. So, with the basis of one of the CSS hero Stu Nicholls' (http://www.cssplay.co.uk) code, i came up with this.
It's a centered, 4 rounded corners navbar that changes color on hover. It works in IE6, FF, Flock, Opera, and if someone could check the MAC ones, i would appreciate it.
You can see it in action here (http://ivar.smugmug.com).
There is quite a bit of code, but you can copy/paste it all, and then change a few things so it works for you.
the HTML: <div id="menu_rounded">
<ul>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK1</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK2</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK3</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK4</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK5</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK6</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
</ul>
</div>
The green stuff is where the links to the appropriate pages go.
The blue stuff is where the word(s) that appear on the button go
the CSS: /* GENERAL */
#menu_rounded {
display: table;
margin: 0 auto;
padding: 1em; /* the padding around the menu itself */
background: transparent;
white-space: nowrap;
}
* html #menu_rounded {
display: inline-block;
width: 1px;
padding: 0 2px;
}
#menu_rounded ul {
display: table;
margin: 0 auto;
height: 1%;
padding: 0;
list-style-type: none;
background: transparent;
}
#menu_rounded li {
display: table-cell;
padding: 0;
padding-right: .3em; /* the padding on the right of the buttons */
padding-left: .3em; /* the padding on the left of the buttons */
}
* html #menu_rounded li {
display: inline;
}
.menu_button {
background:transparent;
}
.menu_button span {
text-align:center;
color:#ffffff; /* the color of the text on the buttons */
margin:0;
font-weight:normal;
}
/* BOX-LAYOUT */
.xtop {
display: block;
background: transparent;
font-size: 1px;
}
.xb1, .xb2, .xb3, .xb4 {
display:block;
/* hide overflow:hidden from IE5/Mac */
/* \*/
overflow: hidden;
/* */
}
.xb1, .xb2, .xb3 {height:1px;}
.xb2, .xb3, .xb4 {
background: #660000; /* the color of the background */
border-left:1px solid #fff; /* the color of the border */
border-right:1px solid #fff; /* the color of the border */
}
.xb1 {
margin:0 5px;
background:#fff; /* the color of the border */
}
.xb2 {
margin:0 3px; border-width: 2px;
}
.xb3 {
margin:0 2px;
}
.xb4 {
margin: 0 1px; height: 2px;
}
.xboxcontent {
display:block;
background:#660000; /* the color of the background */
border-right: 1px solid #fff; /* the color of the border */
border-left: 1px solid #fff; /* the color of the border */
}
/* LINKS */
a.xmenu2,
a.xmenu2:visited {
display:block;
text-decoration:none;
width:9em; /* the width of the buttons, can also be given in 'px'. Examples: width: 20px; */
font-size:0.8em;
}
* html a.xmenu2,
* html a.xmenu2:visited {
display:inline-block;
margin: 0 0px;
}
a.xmenu2:hover {
background:transparent;
cursor:pointer;
}
a.xmenu2:hover span {
color:#660000; /* the color of the words in the menu on hover */
}
a.xmenu2:hover .xboxcontent,
a.xmenu2:hover .xtop {
background:#ffffff; /* the color of the background on hover */
border-color:#660000; /* the color of the border on hover */
}
a.xmenu2:hover .xb1 {
background: #660000; /* the color of the border on hover */
}
a.xmenu2:hover .xb2,
a.xmenu2:hover .xb3,
a.xmenu2:hover .xb4 {
background:#ffffff; /* the color of the background on hover */
border-color:#660000; /* the color of the border on hover */
}
All the yellow stuff is explanation
Because the way it is written, all the colornumbers that i have given the same color in this example need to be the same. (well they don't need to be, but you can get some very interesting buttons if they are not :)
So, all the purple stuff has to be the same, all the red stuf, all the green stuff and all the orange stuff.
If you want to add a button, you can copy/paste a whole section with the li tag:
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK2</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li> the same goes for removing a button.
Comments, suggestions and improvements very welcome.
It's a centered, 4 rounded corners navbar that changes color on hover. It works in IE6, FF, Flock, Opera, and if someone could check the MAC ones, i would appreciate it.
You can see it in action here (http://ivar.smugmug.com).
There is quite a bit of code, but you can copy/paste it all, and then change a few things so it works for you.
the HTML: <div id="menu_rounded">
<ul>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK1</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK2</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK3</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK4</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK5</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK6</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li>
</ul>
</div>
The green stuff is where the links to the appropriate pages go.
The blue stuff is where the word(s) that appear on the button go
the CSS: /* GENERAL */
#menu_rounded {
display: table;
margin: 0 auto;
padding: 1em; /* the padding around the menu itself */
background: transparent;
white-space: nowrap;
}
* html #menu_rounded {
display: inline-block;
width: 1px;
padding: 0 2px;
}
#menu_rounded ul {
display: table;
margin: 0 auto;
height: 1%;
padding: 0;
list-style-type: none;
background: transparent;
}
#menu_rounded li {
display: table-cell;
padding: 0;
padding-right: .3em; /* the padding on the right of the buttons */
padding-left: .3em; /* the padding on the left of the buttons */
}
* html #menu_rounded li {
display: inline;
}
.menu_button {
background:transparent;
}
.menu_button span {
text-align:center;
color:#ffffff; /* the color of the text on the buttons */
margin:0;
font-weight:normal;
}
/* BOX-LAYOUT */
.xtop {
display: block;
background: transparent;
font-size: 1px;
}
.xb1, .xb2, .xb3, .xb4 {
display:block;
/* hide overflow:hidden from IE5/Mac */
/* \*/
overflow: hidden;
/* */
}
.xb1, .xb2, .xb3 {height:1px;}
.xb2, .xb3, .xb4 {
background: #660000; /* the color of the background */
border-left:1px solid #fff; /* the color of the border */
border-right:1px solid #fff; /* the color of the border */
}
.xb1 {
margin:0 5px;
background:#fff; /* the color of the border */
}
.xb2 {
margin:0 3px; border-width: 2px;
}
.xb3 {
margin:0 2px;
}
.xb4 {
margin: 0 1px; height: 2px;
}
.xboxcontent {
display:block;
background:#660000; /* the color of the background */
border-right: 1px solid #fff; /* the color of the border */
border-left: 1px solid #fff; /* the color of the border */
}
/* LINKS */
a.xmenu2,
a.xmenu2:visited {
display:block;
text-decoration:none;
width:9em; /* the width of the buttons, can also be given in 'px'. Examples: width: 20px; */
font-size:0.8em;
}
* html a.xmenu2,
* html a.xmenu2:visited {
display:inline-block;
margin: 0 0px;
}
a.xmenu2:hover {
background:transparent;
cursor:pointer;
}
a.xmenu2:hover span {
color:#660000; /* the color of the words in the menu on hover */
}
a.xmenu2:hover .xboxcontent,
a.xmenu2:hover .xtop {
background:#ffffff; /* the color of the background on hover */
border-color:#660000; /* the color of the border on hover */
}
a.xmenu2:hover .xb1 {
background: #660000; /* the color of the border on hover */
}
a.xmenu2:hover .xb2,
a.xmenu2:hover .xb3,
a.xmenu2:hover .xb4 {
background:#ffffff; /* the color of the background on hover */
border-color:#660000; /* the color of the border on hover */
}
All the yellow stuff is explanation
Because the way it is written, all the colornumbers that i have given the same color in this example need to be the same. (well they don't need to be, but you can get some very interesting buttons if they are not :)
So, all the purple stuff has to be the same, all the red stuf, all the green stuff and all the orange stuff.
If you want to add a button, you can copy/paste a whole section with the li tag:
<li>
<a class="xmenu2" href="http://nickname.smugmug.com/#">
<b class="menu_button"><b class="xtop"></b><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b>
<span class="xboxcontent">LINK2</span>
<b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b><b class="xtop"></b></b>
</a>
</li> the same goes for removing a button.
Comments, suggestions and improvements very welcome.