Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-02-2011, 06:40 PM   PM User | #1
giantpiazza31
New to the CF scene

 
Join Date: Oct 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
giantpiazza31 is an unknown quantity at this point
Tabbed Navigation using HTML and CSS only

I'm trying to make navigation tabs using a table - HTML and CSS only (I know this is not the best or best-practices way to do it). The selected tab should have a different background than the unselected one. I'm trying to do this using a non displayed radio button, and the "checked" attribute, but for some reason, I can't use a complex compound selector.

Here is my HTML:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> 
		<head>
			<title>Tabs</title>
			
			<link rel="stylesheet" type="text/css" href="tab2.css" /> 
		</head>
		
		<body>
			<table class="tabs">
				<tr>
					<td><input type="radio" name="choices" id="inventory" checked="checked" /><span class="before"><span class="after"><span class="middle"><a href="inventory.html" class="linked">Inventory</a></span></span></span></label></td>
					<td><span class="before"><span class="after"><span class="middle"><input type="radio" name="choices" /><a href="orderInfo.html">Order Information</a></span></span></span></td>
					<td><span class="before"><span class="after"><span class="middle"><a href="accounts.html">Accounts</a></span></span></span></td>
					<td><span class="before"><span class="after"><span class="middle"><a href="shippers.html">Shippers</a></span></span></span></td>
					<td><span class="before"><span class="after"><span class="middle"><a href="suppliers.html">Suppliers</a></span></span></span></td>
				</tr>			
			</table>
			
			<hr />
			
		
		</body>
	
	






	</html>
and here is my CSS
Code:
.tabs{
	font-family: Tahoma;
	font-size: 13px;
	border-spacing:5px;
}



a:link{
	text-decoration:none;
	color:black;
}
	
a:hover{
	color:#cc6600;
	cursor:pointer;
}



hr{
	border:none;
	background-color:#cccccc;
	margin-top:-5px;
	height:1px;
}



.middle {
	background-image:url('mid.gif');
	background-repeat: repeat;
	background-position: left top;
	padding-left:4px;
	padding-right:2px;
	padding-top:3px;
	margin-left:-3px;
	padding-bottom: 3px;
}

.after {
	background-image:url('right.gif');
	background-repeat: no-repeat;
	background-position: right top;
	padding:3px;
	

}

.before{
	background-image:url('left.gif');
	background-repeat: no-repeat;
	background-position: left top;
	padding:3px;
	
}



input[checked="checked"] + .before{
	background-image:url('left-selected.gif');
	background-repeat: no-repeat;
	background-position: left top;
	padding:3px;
}

input[checked="checked"] + .before + .after{
	background-image:url('right-selected.gif');
	background-repeat: no-repeat;
	background-position: right top;*/
	padding:3px;
}

input[checked="checked"] + .before + .after + .middle{
	background-image:url('mid.gif');
	background-repeat: repeat;
	background-position: left top;
	padding-left:4px;
	padding-right:2px;
	padding-top:3px;
	margin-left:-3px;
	padding-bottom: 3px;
}
giantpiazza31 is offline   Reply With Quote
Old 10-02-2011, 11:41 PM   PM User | #2
Apostropartheid
The Apostate


 
Apostropartheid's Avatar
 
Join Date: Oct 2007
Posts: 3,215
Thanks: 16
Thanked 265 Times in 263 Posts
Apostropartheid is on a distinguished road
Is there any rational reason to use tables here?
__________________
Blog | Twitter
Useful links: W3C HTML Validator | W3C CSS Validator | HTML 5 Guide
CF: HTML & CSS Resources/Tutorials Thread | HTML & CSS Posting Rules and Guidelines
Remember: no link, no code, no help!
Apostropartheid is offline   Reply With Quote
Old 10-03-2011, 02:33 PM   PM User | #3
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,375
Thanks: 18
Thanked 349 Times in 348 Posts
sunfighter is on a distinguished road
read this: http://www.w3schools.com/css/css_navbar.asp
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Tags
css, html, navigation, radio, tabs

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:21 PM.


Advertisement
Log in to turn off these ads.