Closed (fixed)
Project:
Zen
Version:
6.x-1.0-beta2
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
21 Aug 2008 at 03:12 UTC
Updated:
2 Aug 2010 at 06:16 UTC
Hi,
I am trying to build a zen subtheme with the navbar displayed at the very top of the page. I am using the layout-liquid.css file, although I'm not sure it makes a difference which layout file I chose to use. I want to achieve this functionality without losing the content first, navigation second aspect of the zen theme. Can anyone help me with some instruction on how to move the navbar to the top of the page to where it looks good in all major browsers.
Thanks,
Jon Antoine
Comments
Comment #1
carteriii commentedMy limited knowledge of Zen is causing me to struggle right now as well, so I can't offer too many specifics, but I think I can at least point you in the right direction. First of all, the nav bar is actually defined within the content div, but the header div is not. I believe you'll have to modify page.tpl.php and either move the nav bar out of and above the content div, or move the header down into the the content. It appears that the various regions within the main content div adjust their top margin to accommodate the size of the nav bar, so just be aware that moving most anything will certainly have a ripple effect on everything else.
Comment #2
iamnoskcaj commentedBelieve it or not, this is actually pretty easy to accomplish. Of course there's always more than one way to accomplish things (usually MANY)... but in my experience, you need to change the page.tpl.php as well as your layout.css
The exact answer depends on a few things, such as:
• Exactly where does the navbar need to be located? (above the logo/title and flush at the top -or- paralell to the logo/title on it's right?)
• Do you use search, and do you want the search to appear next to the navbar like the default behavior?
I would be happy to help you with the specific… just tell me a little more about those few things I listed above.
Comment #3
carteriii commentedI don't want to completely hijack this thread, but I believe my navbar question is directly on topic. Why is the navbar is floated, setting the margin-right to -100%, and then using the class "with-navbar" to shift everything else down using a margin-top value equal to the height of the navbar?
Naively it seems that the same result could be achieved (navbar on top, everything else lined up immediately below and with the same left edge) by listing the navbar first without being floated (and with 100% width). Everything else would then simply appear below the navbar just as it does now. Perhaps the pure html sequencing is the answer, that all the extra work is simply to make the content div appear first in the html before the navbar (for search engine optimization). Is this all just for that, or is there some other purpose which I simply haven't (yet) been able to figure out?
Thanks in advance.
Comment #4
johnalbinThe same visual result would be achieved by doing that. But from an SEO and/or accessibility standpoint, having the content first is better.
But you are more than welcome to copy the page.tpl.php to your sub-theme, move the navbar above #main. and remove the "with-navbar" class.
In about 90% of the themes I create, I have to tweak the page.tpl.php file in my sub-theme.
Comment #5
jantoine commentedI have actually solved my problem keeping the navbar code below the actual content code for SEO purposes but displaying it visually flush at the top of the page. Below are the steps I used to achieve this effect. I would appreciate it if any css guru's could overlook my solution and let me know if there is any incorrectness as far as SEO goes. This solution works great for the fixed layout and has a few width problems with the liquid layout. I have checked this solution in IE 6 & 7, FireFox 3, and Safari 3.
1. Move the #navbar container outside the #main-inner container into the #page-inner container to become siblings with the #header, #main, and #footer containers.
2. Remove the "with-navbar" class from the #main-inner container.
3. Set the margin-top property to 0 for the .with-navbar #content, .with-navbar #sidebar-left, and .with-navbar #sidebar-right containers.
4. Set the following properties for the body tag:
position: relative;
5. Set the following properties to the #header, #main, and #footer containers:
float: left; /* Float left for FireFox */
//float: none; /* Float none for IE */
width: 100%;
6. Set the following properties to the #header container:
//margin-top: 40px; /* Margin-Top set to navbar height for IE */
padding-top: 40px; /* Padding-Top set to navbar height for FireFox */
//pading-top: 0; /* Reset Padding-Top to 0 for IE */
7. Set the following properties for the #navbar container:
display: block;
height: 40px;
position: absolute;
top: 0;
width: 100%;
Cheers,
Jon Antoine
www.antoinesolutions.com
Comment #6
johnalbinYep, that should work.
Comment #7
mimhakkuh commentedneat solution, thx - appreciated :)
Comment #9
benjarlett commentedThis I belive is the code for Zen 2.0
1. Move the #navigation container outside the #main-inner container into the #page container to become siblings with the #header, #main-wrapper, and #footer containers.
2. Remove the "with-navbar" class from the #main container.
3. Impliment this css.
#main-wrapper, #header, #footer{
float: left; /* Float left for FireFox */
//float: none; /* Float none for IE */
width: 100%;
}
#header{
//margin-top: 40px; /* Margin-Top set to navbar height for IE */
padding-top: 40px; /* Padding-Top set to navbar height for FireFox */
//pading-top: 0; /* Reset Padding-Top to 0 for IE */}
#navigation{
display: block;
height: 40px;
position: absolute;
top: 0;
width: 100%;
}
#page{
position: relative;
}