Sunday, July 19, 2009

Aligning the Header Image

In a previous post I talked about how the Blogger’s header image gets resized depending on the size of the image, the available space in the header and the configuration of the header widget. In this one, I will answer another question I get so often from my readers; “How can I center the header image?" This handy tip will help you not only to center align the header image, but also to right align it, if required.

First add the header image as you would normally do it. Then, to center Blogger’s header image, simply add the following CSS snippet to your template’s skin. (Read this to learn more about the Blogger template structure)

For placement “Behind title and description” add:

#header-inner {
margin-left: auto;
margin-right: auto;
}

For placement “Instead of title and description” add:

#header-inner img {
margin-left: auto;
margin-right: auto;
}

You can add it anywhere inside the skin. But, to keep all header related styles close apart, add it after a style such as the #header-wrapper or #header.

To right align the header image, simply remove the “margin-right: auto;” statement from the above block.

This trick has been tested on Denim, Denim Stretch, Rounders and Scribe templates. (Minima has it by default). But it should work on all other default Blogger templates. If it doesn’t work on a particular template, please let me know.

11 comments:

Chiew said...

When I first created my blog, I had a lot of problems trying to make it do what I wanted, and one of the problems was the header. In the end, after a lot of fooling around, I had to extend the width of my header and remove the background image. The only problem now is that I have a square cornered header. I used to know how to round corners in Photoshop but I can't remember now. Even after following a few howto's in the Net, I've failed.

What's your recommendation? Should I put back the background image and amplify my header to be larger than it so that I get rounded corners? Or perhaps someone could help me round my header... ;-)

ids said...

@ Chiew

What's is the blog URL? Without looking at it I can't say anything.

Chiew said...

The blog is linked at my name. ;-)
http://acliltoclimb.blogspot.com

ids said...

@ Chiew,

Oh, I missed it. You have commented off the background images for the header. If you add them back, you can get the original rounded corners. If you want the current header to be rounded, then you will have to edit it.

My file host has changed. If you are adding the images in my tutorial, please re-do step (5).

Chiew said...

I commented them off because my header was smaller than the background image and all I got were the handles. Could you tell me the exact size of the image?

ids said...

@ Chiew,

I replied to you in email.

story_weaver said...

For months I've been trying to get this image;
http://1h3.ggpht.com/_LXx0Gfk_Yjo/Sps11C13IeI/AAAAAAAAAgU/qorAvF_wTV0/writersense.jpg
to fit my header. Help?

Nita said...

What I would like to know is the exact size of the header image I need to load on to my minima stretch template. Centering is not the problem.

jgpietsch said...

Hi, I have created my own image for a blogger rounders template. However, I don't want any of their gif overlays or margins, (I've already matched all that in my image. When I put the image in, margins continue all around my image. Any thoughts? Thanks!

ids said...

@ jgpietsch

You can disable the existing corner images by modifying the background images applied for #header-wrapper and #header CSS sections.

dave said...

Thank You, Thank You , Thank You ! ! ! ! !

Ive been having this header issue for some time now. It is Finally Centered.

Blogging U

Post a Comment

Thanks in advance for all your comments and suggestions. They are very much appreciated.

IMPORTANT:
If you have a specific technical question, please email me with a description of the problem and the blog's URL.