![]() |
| | #1 (permalink) |
| Administrator Enthusiast | Evening, I've seen a couple of similar threads out there (there's one on alistapart which I'll post a link to shortly. However, I've come up with my own way of doing CSS tabs, which I find easier to understand, and also less strenuous on download times as the images are generally smaller than the method discussed on alistapart. What You'll Need
The HTML Right - we need a set of markup to demonstrate the end result. Code: ...
<body>
<div id="header"> </div>
<div id="tabs">
<ul>
<li class="active"><a href="/"></span>Home</span></a></li>
<li><a href="/"></span>About</span></a></li>
<li><a href="/"></span>Blablabla</span></a></li>
</ul>
</div>
...
Generally, this is completely up to you - I use 3 images for each type of tab - left corner, right corner, and a tab background. You'd do these images for both active and inactive tabs depending on your requirements. The Style For the tabs, we're using a list - which we're going to float in order to break out of the conventional layer model. This class defines the main container of the tab strip Code: div#tabs {
float:left;
clear:both;
height:24px;
background:url(Images/tab-bar-background.jpg) repeat-x 0 0;
}
Code: div#tabs ul {
float:left;
height:24px;
margin:0;
padding:0;
}
Code: div#tabs ul li {
float:left;
background:url(Images/tab-inavtive-background.jpg) repeat-x 0 0;
height:24px;
list-style-image:none;
list-style-type:none;
}
div#tabs ul li.active {
background:url(Images/tab-active-backgroung.jpg) repeat-x 0 0;
}
Next we have the styles for the anchors Code: div#tabs ul li a:link, div#tabs ul li a:visited, div#tabs ul li a:hover, div#tabs ul li a:active {
display:block;
float:left;
padding:0 10px 0 0;
height:25px;
text-decoration:none;
background:url(Images/tab-inactive-right.jpg) no-repeat 100% 0;
}
div#tabs ul li.active a:link, div#tabs ul li.active a:visited, div#tabs ul li.active a:hover, div#tabs ul li.active a:active {
background:url(Images/tab-active-right.jpg) no-repeat 100% 0;
}
The final piece of the puzzle is the span class Code: div#tabs ul li a span {
display:block;
float:left;
padding:0 0 0 10px;
height:24px;
background:url(Images/tab-inactive-left.jpg) no-repeat 0 0;
}
div#tabs ul li.active a span {
background:url(Images/tab-active-left.jpg) no-repeat 0 0;
}
Have a play with it, if you need any more help, just ask the question Regards
__________________ Sean Johnstone To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Tutorials: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on creating navigation tabs using CSS To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on PHP custom user authentication |
| | |
| | #2 (permalink) |
| Administrator Disciple | This is absolutely fantastic. I have to admit, i'm not much of a coder myself, but I understand what it is i'm reading as far as scripting languages go and this one does actually looks different than some of the other css tabs I have used for my sites. I don't mean to go off topic here, but this reminds me of my current project; what i want to do for our gallery here. I'm interested in creating an ajax navigation for gallery categories not much different from the browser on deviantart.com. How difficult would it be to come up with something like that specifically designed for the photopost script?
__________________ To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - A list of resources for 3D Developers To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - A list of resources for design in motion with Adobe After Effects To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Usefully resources for freelance web developers To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tips and discussion about search engine optimization To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorials submitted by ny-dev members |
| | |
| | #3 (permalink) |
| Administrator Enthusiast | It depends what you've already got - it's quite simple - if you use the prototype library - you can quite easily update that section of the page. If it's just navigation, it's particularly easy - it gets harder to do custom AJAX when posting data. Let me know.. Here's the link to the alistapart tutorial should anyone be interested. Regards
__________________ Sean Johnstone To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Tutorials: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on creating navigation tabs using CSS To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on PHP custom user authentication |
| | |
| | #4 (permalink) | ||
| Administrator Disciple | Quote:
Quote:
As a new admin, just for future reference, the Photopost admin control panel is different from the forum's admin control panel. The URL is http://www.ny-dev.com/forums/gallery/adm-index.php .No problems posting this link in the public forums as it is password protected and you must be an admin to view the admin control panel. If you were inclined as to kindly post the code in another released tutorials thread it would be greatly appreciated. Im sure our members would love to see it.
__________________ To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - A list of resources for 3D Developers To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - A list of resources for design in motion with Adobe After Effects To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Usefully resources for freelance web developers To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tips and discussion about search engine optimization To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorials submitted by ny-dev members | ||
| | |
| | #5 (permalink) |
| Administrator Enthusiast | Sorry! http://alistapart.com/articles/slidingdoors/ is the link to the tutorial on alistapart!! Will look into it sometime soon Danny Regards
__________________ Sean Johnstone To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Tutorials: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on creating navigation tabs using CSS To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on PHP custom user authentication |
| | |
| | #6 (permalink) |
| Administrator Enthusiast | Danny, I've looked at the admin panel for the gallery, and hav to say - I'm completely flummoxed. No idea how to easily integrate ajax without overhauling most of the system!! Let me play around with some ideas and get back to you Regards
__________________ Sean Johnstone To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Tutorials: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on creating navigation tabs using CSS To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on PHP custom user authentication |
| | |
| | #7 (permalink) |
| Administrator Enthusiast | I've added a few images from my own most recent design for johnboulder to illustrate the theory. Tabs Background: tabsbackground.jpg Active Tab Left: tableft.jpg Active Tab Right: tabright.jpg Active Tab Background: tabbackground.jpg In this case, I'm not using any images for inactive tabs. Here's a screeny of the tabs in action: jbscreen.jpg
__________________ Sean Johnstone To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Tutorials: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on creating navigation tabs using CSS To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on PHP custom user authentication |
| | |
| | #8 (permalink) | ||||||
| Administrator Disciple | Quote:
http://www.shutteralley.com Quote:
Quote:
__________________ To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - A list of resources for 3D Developers To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - A list of resources for design in motion with Adobe After Effects To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Usefully resources for freelance web developers To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tips and discussion about search engine optimization To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorials submitted by ny-dev members | ||||||
| | |
| | #9 (permalink) |
| Administrator Enthusiast | I will have to look into it in more depth Danny Will let you know if I come up with anything
__________________ Sean Johnstone To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Tutorials: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on creating navigation tabs using CSS To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on PHP custom user authentication |
| | |
| | #10 (permalink) |
| Junior Member Newb | If I may I would like to simplifie your code some. HTML: Code: <ul id="tabs">
<li class="active"><a href="/"><span>Home</span></a></li>
<li><a href="/"><span>About</span></a></li>
<li><a href="/"><span>Blablabla</span></a></li>
</ul>
Code: <div id="containerMain">
<div id="sectionHead">...</div>
<div id="sectionBody">...</div>
<div id="sectionFoot">...</div>
</div>
Code: #tabs {
clear:both;
background: url(Images/tab-bar-background.jpg) repeat-x 0 0;
}
#tabs,
#tabs li {
float:left;
/* This could be better if the tabs are allowed to scale with the text. */
height: 24px;
margin: 0;
padding: 0;
list-style-image: none;
list-style-type: none;
}
#tabs .active {
background: url(Images/tab-active-backgroung.jpg) repeat-x 0 0;
}
#tabs a, #tabs a span {
display: block;
float: left;
padding: 0;
height: 24px;
}
#tabs a:link,
#tabs a:visited,
#tabs a:hover,
#tabs a:focus,
#tabs a:active {
padding-right: 10px;
text-decoration:none;
background: url(Images/tab-inactive-right.jpg) no-repeat 100% 0;
}
#tabs .active a:link,
#tabs .active a:visited,
#tabs .active a:hover,
#tabs .active a:focus,
#tabs .active a:active {
background: #333333 url(Images/tab-active-right.jpg) no-repeat 100% 0;
}
#tabs a span {
padding-left: 10px;
background: url(Images/tab-inactive-left.jpg) no-repeat 0 0;
}
#tabs .active a span {
background: url(Images/tab-active-left.jpg) no-repeat 0 0;
}
Btw Dan the HTML code block doesn't keep the formatting.
__________________ Logic Earth - Broken Mind of the World. |
| | |
| | #11 (permalink) |
| Administrator Disciple | Hey bro, Good to see you finally posting on the forums. And what posts they are! Very nice friend. Very insightful posts. Here's hoping we see more from you. I appreciate the heads up on the HTML code-blocks. Can you give me more detail as to what is happening when you are posting the HTML?
__________________ To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - A list of resources for 3D Developers To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - A list of resources for design in motion with Adobe After Effects To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Usefully resources for freelance web developers To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tips and discussion about search engine optimization To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorials submitted by ny-dev members |
| | |
| | #12 (permalink) |
| Administrator Enthusiast | Hey Logic, Glad to see some corrections going on!! One minor note on the using of a wrapper DIV around my UL - I've found, when floating content, IE gets a little nutty - using a surrounding div is one way to make the page not break out of it's own layout (well, I found anyway) - and I've used it as such for a while now (of course, I could be mistaken...) Thanks for the reply Regards
__________________ Sean Johnstone To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Tutorials: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on creating navigation tabs using CSS To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - Tutorial on PHP custom user authentication |
| | |