Digg-like navigation bar using CSS
- Published in Css
- Hits: 1460
ÂÂ
The result is something like this:

ÂÂ
Step 1: HTML page
Create a new HTML page and copy and paste the following code inside <body> tag:
ÂÂ
<div id="topbar">
<a href="/p1.html"><span>All</span></a>
<a href="/p2.html" class="active"><span>News</span></a>
<a href="/p3.html"><span>Video</span></a>
<a href="/p4.html"><span>Images</span></a>
</div>
<div id="middlebar">
<a href="/p1.html"><span>Technology</span></a>
<a href="/p2.html"><span>World</span></a>
<a href="/p3.html"><span>Science</span></a>
<a href="/p4.html"><span>Gaming</span></a>
</div>
In the second link, "News", I added the class "active" (in bold).
If you use URL variables and PHP to implement a dynamic navigation bar with some topics,
if is defined an URL variable equal to "topic name" (in this case equal to "news")
then add the attribute class="active" to the link. The code to implement this simple tip is very simple:
ÂÂ
<?php if(isset($_GET['news'])){ echo 'class="active"';}?>
ÂÂ
Step 2: rounded corners with liquid design for links
Before to start, I spend few rows to explain how to implement this simple effect using CSS.
The typical way is using this simple structure:
ÂÂ
 
ÂÂ
<a href="mypage.html"><span>All</span></a>ÂÂ
ÂÂ
Step 3: CSS file, #topbar
Create a new CSS file (style.css) and copy and paste the following code for #topbar element (remeber to link this file in your HTML page):
ÂÂ
#topbar{
font-size:14px;
color:#3b5d14;
background:#b2d281;
font-weight:bold;
padding:6px;
overflow:auto;
height:1%;
clear:both;
}
#topbar a{
color:#3b5d14;
text-decoration:none;
margin:0 10px;
height:23px;
line-height:23px;
float:left;
display:block;
}
a.active{
height:23px;
line-height:23px;
background:url(pic/tb_a.png) right top no-repeat;
padding-right:10px;
}
a.active span{
background:url(pic/tb_span.png) left top no-repeat;
height:23px;
display:block;
padding-left:10px;
}
ÂÂ
Step 4: CSS file, #middlebar
In the same CSS file (style.css), add the following code:
ÂÂ
ÂÂ
#middlebar{
font-size:11px;
color:#3b5d14;
background:#90b557;
font-weight:bold;
padding:6px;
overflow:auto;
height:1%;
clear:both;
}#middlebar a{
color:#3b5d14;
text-decoration:none;
margin:0 5px;
padding-right:10px;
height:23px;
line-height:23px;
display:block;
float:left;
background:url(pic/mb_a.png) right top no-repeat;
}
#middlebar a span{
background:url(pic/mb_span.png) left top no-repeat;
height:23px;
display:block;
padding-left:10px;
}
ÂÂ
 Save and test the result!
ÂÂ
Report Broken Link
Use this link and complete the form,to send us broken download link. ( Only members )
