Thesis full-width headers 101

November 14, 2008

tagged as , , , ,

in Blogging

I recently ported my blog to Thesis by DIYthemes.

Thesis has excellent SEO, and with it you can choose the number of sidebars that you want and their position, you can adjust the widths of content and sidebars, and you can change fonts across the webpage… all from dropdown options in the admin area. There are a bunch of other options allowing you to change the nav menu, size of gravatars, comment count, author link, category, date and tag display, and more. If you’re not a coder you can receive assistance with custom CSS and PHP hooks on the forum.

For those reasons and a few others I am now using Thesis. The new full page framework makes it fairly easy to have full-width headers and footers. In this post is a how-to on customising your header.

Full page framework

The first step of making a full-width header and footer is to choose the Full-width framework from the Design Options page.
NB if you have done the coloured background thing with the page framework, selecting full-width will mess it up. You’ll need to rearrange your CSS a bit. The following assumes you haven’t modified much of your design yet.

Prepare header and navigation

The easiest way to swap the positions of the header and navigation is as described in the Thesis documentation, by adding code to custom_functions.php.

remove_action('thesis_hook_before_header', 'thesis_nav_menu');
add_action('thesis_hook_after_header', 'thesis_nav_menu');
Swap header and navigation

Swap header and navigation

Doing that makes the header area structure,

  • div#header_area
    • div.page
      • div#header
      • ul#tabs

Which basically means that div#header_area spans the full width of the page and everything else is inside that.

On the Tip’d blog Chris has created new divs, which make it easier to give the header and nav different backgrounds. If you do that with custom_functions.php I don’t think it’s possible to remove the #header_area. However, for this demonstration I’m going to do it anyway and just hide #header_area with CSS.

Place the following at the very bottom of custom_functions.php.

remove_action('thesis_hook_before_header', 'thesis_nav_menu');
remove_action('thesis_hook_header', 'thesis_default_header');

function full_width_header() { ?>
	<div id="nav_area" class="full_width">
		<div class="page">
			<?php thesis_nav_menu(); ?>
		</div>
	</div>
	<div id="title_area" class="full_width">
		<div class="page">
			<div id="header">
				<?php thesis_default_header(); ?>
			</div>
		</div>
	</div>
<?php }
add_action('thesis_hook_before_html', 'full_width_header');

This adds the nav above the title, or you can take the whole nav_area and move it below the title and before <?php }, to have the nav below the header.

Replace header with new title and navigation

Replace header with new title and navigation

Styling the header with CSS

All your CSS should go in custom.css.

Remove unwanted styles

There are a bunch of borders and related styles that we don’t necessarily want in our new header, so I’m going to remove them. I’ve done it in a specific way that should allow you to add some back in if you want to.

.custom #header_area{display:none;}

.custom #nav_area ul {border-bottom:none; border-left:none;}
	.custom #nav_area ul li {border-width:0; margin-bottom:0; padding-bottom:0; background:none;}

.custom #header {border-bottom:none;}

These styles hide the original header (unfortunately the empty div is still in the markup); remove borders, padding and margin from the nav that were mainly related to current page styles; remove the header double border.

Remove unwanted styles

Remove unwanted styles

Add some new styles

Now we’re set to add some backgrounds and some more space for the nav, which feels a bit squished up the top, as well as some borders, which just make things feel much more complete. Building on the previous CSS:

.custom #header_area{display:none;}

.custom #nav_area {background:#c3d9d6; padding:0.5em 0; border-bottom:1px solid #ddf;}
	.custom #nav_area ul {border-bottom:none; border-left:none;}
		.custom #nav_area ul li {border-width:0; margin-bottom:0; padding-bottom:0; background:none;}

.custom #title_area {background:#de6a61; padding:1em 0; border-bottom:1px solid #c55;}
	.custom #header {border-bottom:none;}
Background colours and borders

Background colours and borders

I like to use background images to spruce things up, then hide the title and description. In thesis you can opt not to show them, but I like to leave them in and hide them in case someone loads the page without CSS and because Google bots don’t care about CSS.

.custom #title_area {background:#de6a61; padding:1em 0 0.5em; border-bottom:1px solid #c55;}
	.custom #header {border-bottom:none; height:150px; padding-top:0; padding-bottom:0; background:url(images/header.png) center left no-repeat;}
		.custom #header #logo {display:none;}
		.custom #header #tagline {display:none;}
Title & description hidden, background image added

Title & description hidden, background image added

Coffee cup is from OpenClipart.org.

The other option is to replace the default title and description in custom_functions.php.

<div id="title_area" class="full_width">
	<div class="page">
		<div id="header">
			<p id="logo"><img src="<?php bloginfo('template_directory') ?>/custom/images/header.png" alt="<?php bloginfo('name') ?>" /></p>
		</div>
	</div>
</div>

The process to customise your footer is similar, but even easier since there is only the one footer element, as opposed to both the title and nav bar. I’ll follow up with a post about footers in due course.

Questions?

If you have any questions, ask away! There is a forum thread so other thesis users can discuss it too.

{ 7 trackbacks }

Full width headers - DIY Themes Forums
11.14.08 at 17:01
Theme Hooks problem - DIY Themes Forums
11.19.08 at 23:45
Thesis footers 101 — kristarella.com
11.25.08 at 16:17
Thesis Theme — December 6, 2008
12.08.08 at 2:38
This Week in Thesis — December 6, 2008
12.11.08 at 20:38
Thesis full-width headers 101 — kristarella.com
01.02.09 at 3:57
logo/header is cut off. stuck! - DIY Themes Forums
01.05.09 at 7:02

{ 19 comments… read them below or add one }

1 Mat Packer 11.14.08 at 17:55

Nice tutorial Krista, pretty sure this will come in handy as I’m taking a good long look at Thesis for a couple of upcoming projects.

Cheers
Mat

2 David Airey 11.14.08 at 19:44

I’ve been wanting a full width header and footer on my site for some time. I’ve also been thinking about a Thesis migration, though the full-blown move over isn’t a priority.

Have you been looking into my thoughts again? :)

3 dinu 11.14.08 at 21:51

will note this :) planning to get thesis soon ;)

4 Gregory Nemer 11.15.08 at 0:45

Wow what a great post!
I was thinking about doing some of these changes on my site but just didn’t know how. I’ll be putting your tips into practice.
They are very easy to follow and I really like the fact that you’ve already given us the html codes.
Thanks again

5 Miguel Wickert 11.15.08 at 2:03

sweet action! Clear tutorial.. I’ve made some changes to my site… What do you think? Oh, how would I add a bit more space between my nav bar and blog title? Thanks!

6 Miguel Wickert 11.15.08 at 2:18

hey, so I’ve got another question. How could I turn my nav bar into the one presented here at http://www.productivity501.com/ ? Thanks!

7 David Evans 11.15.08 at 13:55

This is exactly what I was looking for!

8 Patch 11.15.08 at 17:22

hey, loved your old site and loving your newly ported site :) Thanks for the superb full-width header write up.

9 kristarella 11.16.08 at 17:56

Thanks Mat! Hope it is useful.

David — hah! Nope, no mind reading here, but since a few people asked me about it I’m not surprised more folks have been thinking about it.

Cheers dinu! And Gregory, glad you found it easy to understand. I did give the HTML, but I hope everyone still gets the hang of using it and maybe learns to write some of their own. I found modifying my blog over the years a valuable learning experience.

Miguel, glad you’re getting into customising. You can add more space with .custom #header #logo {margin-top:1em;} in custom.css. That nav bar is characteristic of the Revolution themes by Brian Gardner. Adding a second bar would involve adding a second list of links to the code I gave, e.g.,

	<div id="nav_area_2" class="full_width">
		<div class="page">
			<ul>
				<li><a href="http://www.example.com/1/">Item 1</a></li>
				<li><a href="http://www.example.com/2/">Item 2</a></li>
			</ul>
		</div>
	</div>

That would go in between the first nav_area and the title_area.
As for the rounded corners, there is a thorough screencast at CSS Tricks.

Glad you found what you were looking for David!

10 Miguel Wickert 11.16.08 at 20:18

Hey Kristarella

Yeah, one step at a time. :) Spectacular! Thanks for the help! I sent ya a message via your contact form.

11 Allan 11.21.08 at 14:14

Hi Kristarella
Everything is working but for a big white space between the nav bar and the main page area as shown here.
I’m sure the solution is simple, but I just can’t work it out.
Thanks for you help with this tutorial. Much appreciated.

cheers

Allan

12 Allan 11.21.08 at 16:37

Hi Kristarella

Finally figured it out. Had not added
.custom #header_area{display:none;}
to custom css.
Check it out now Fleur McDonald

cheers

Allan

13 kristarella 11.21.08 at 18:49

Hi Allan. Glad you found it. Very nice work! Great pic.

14 Bruce Keener 12.10.08 at 8:31

What a great tutorial, kristarella! I noticed it sometime back and am finally getting around to implementing it on my test site. Just one question: I take it that the top two pieces of code,

remove_action( ‘thesis_hook_before_header’, ‘thesis_nav_menu’ );
add_action( ‘thesis_hook_after_header’, ‘thesis_nav_menu’ );

are not really needed in view of the code you provide in the remainder of the discussion. Is that true? Right now my test site seems to be working without those two pieces, although I have not tried validating it yet. Just looking for some clarification before I ultimately do this to my main site.

Thanks again. I’ll read the footer tutorial, too.

15 kristarella 12.10.08 at 8:36

Hi Bruce, that’s corrrect. The first bit of code is one way to change the location of the nav. It is not needed with the rest of the code.

16 ClarkeW 12.16.08 at 13:52

Great tutorial Kristarella,

Any idea as to why this would shift everything to the right if you try to set Thesis to 3 columns with the content in the middle and a sidebar on the right and one on the left? This seems to be the only configuration that it does it on and I cannot figure out why.

17 John 12.22.08 at 7:55

Thanks Krista! After customizing the footer, this was my next question for you. Nice to see it already answered so simply.

18 Alex 01.01.09 at 18:28

Brilliant tutorial and exactly what I was looking for. Reads very well and the instructions were simple to follow.

Thanks.

19 Michelle Vandepas 01.04.09 at 4:41

I’m stuck and need help. I’ve emailed you, please can you contact me? Thanks!

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment policy