
Following several requests after the publishing Blog Improvement 101 - Adding Functionality to My Header and 3 Answers to Expect From a Good Header, I’m going to explain the way you could add a text container to your header, just like I did, showcasing my Featured Articles.
Disclaimer: Knowing only bits and pieces of html and css, this is going to be a Fools’ guide from a slightly more experienced Fool. I beg pardon of the savvy web developers for my crude adaptations.
It is written for WordPress bloggers, but with a little adaptation it could be used on any platform where you can access the HTML of your theme or template.
If your theme is fluid width, when resizing the width of the browser window would change the width of your blog’s page, you’d want the container to move with the page. Go to Code for Fluid Width
If you theme is fixed width, where resizing the width of the browser window would not change the width of your blog’s page, you would want the container to be static as well and stay on the same location on the page. Mine is a fixed width theme, so try resizing the browser window to see what I mean. Go to Code for Fixed Width.
Just before the <body> tag of your header.php add the following code:
<style type=”text/css”>
body {
font-size: 12px;
color: #333;
}.fixed_container1 {
position:relative;
top: 125px; /*Adjust this to position the container*/
left: 120px; /*Adjust this to position the container*/
width:350px; /*This is the width of my container, could be adjusted if needed*/
height:12px; /*This is the height of my container, could be adjusted if needed*/
}
</style>
If you plan to have more than one floating container like I do, copy .fixed_container1 just under it, rename and adjust the position according to your wishes.
After the <body> tag of your header.php, add the following code:
<div class=”fixed_container1″>
<p>Here could be anything you want. /p>
</div>
If you plan to have more than one floating container like I do, add another div with appropriate class right after the closing </div> of the fixed_container1.
Just before the <body> tag of your header.php add the following code:
<style type=”text/css”>
body {
font-size: 12px;
color: #333;
}#big_container { /*This is the transparent container where the text container(s) would be “floating”*/
position:absolute;
top: 0%; /*Adjust this if your header not on the top*/
left: 50%;
width:900px; /*This should be the width of your header*/
height:0px;
margin-top: 0px; /*Crucial: set to a negative number, half of your height*/
margin-left: -450px; /*Crucial: set to a negative number, half of your width*/
}.floating_container1 { /*This is the text container for the Featured Articles*/
position:relative;
top: 125px; /*Adjust this to position the container*/
left: 120px; /*Adjust this to position the container*/
width:350px; /*This is the width of my container, could be adjusted if needed*/
height:12px; /*This is the height of my container, could be adjusted if needed*/
}</style>
If you plan to have more than one floating container like I do, copy .floating_container1 just under it, rename and adjust the position according to your wishes.
After the <body> tag of your header.php, add the following code:
<div id=”big_container”>
<div class=”floating_container1″>
<p>Here could be anything you want. /p>
</div>
</div>
If you plan to have more than one floating container like I do, add another div with appropriate class before the closing </div> of the big_container (the last one).
This is where I leave you to do your tweaking. Let me know if you need any more help with this.
- Alex
Technorati Tags: div, css, header functionality, header, fools’ guide, how-to, fluid width, fixed width, centered div
If you enjoyed this post, make sure you subscribe to my RSS feed!
Great, wonderful! Bookmarked it in case someday in the future I actually dare touching my header!
For now I am afraid I will have to stick to adding another page in my topmenu … darn … your way is so much more useful!
Mirjam’s last blog post..Dilemma of a Blogger Follow Up
Also bookmarked this as a reference for myself. I am currently learning CSS and then hopefully PHP.
Phil Benwell’s last blog post..First tutorial has been added.
@Mirjam:
Come on and touch it!
Don’t be afraid, and remember that one hour of hard work on it today will give you, and your readers, many hours of enjoyment in the future.
I’m thinking about adding another page in my topmenu in addition to the header improvements. I thought about an ‘Article Page’, which will serve as a directory for all my articles.
What do you think?
@Phil:
Good luck with your studies, Phil.
haha Alex, if only you knew how many times the “one hour” have turned into late-nighters with me up at 4 or 5 in the morning for having gone ahead and changing codes … completely screwing up whole themes, layouts, once even resulting in having to completely take off a blog and domain and install everything from scratch… you might understand I am a bit weary of doing so plus sleepdeprived… (ROFL at my own stupidities!)
Did teach me to install an automatic back up plug though, so it was worth the lesson!
About adding an article page: if you look at my menu at the moment, you will see a Sitemap (automated by Dragon Design) which lists all posts in their corresponding categories, plus an extra Top Posts page I added this morning, which lists the 15 most popular posts of my blog.
I have tried adding an article page using a plugin in the past but *blushing* without great result, so I took it off…
I was actually planning a complete redesign for next month, so I will definately keep this post in mind
I am just too hung up still on my favorite flowers at the moment, eventhough they add nothing of value to my blog… they just make me personally smile evertime I enter… :S
Mirjam’s last blog post..Dilemma of a Blogger Follow Up
Great post and a great idea to put your featured articles or latest news.
@Make Money Blogging:
Thanks!
@Mirjam:
Yes, I know what you mean. I “redesigned” a couple of times only to find my blog has crashed.
Wait for my next post to find how to never let that happen again!! (ooooh, how exciting…)
haha … never touching the codes late at night? :P:P:P
have a good weekend, will be checking back in to see what you are coming up with, especially since I am planning on changing my theme soon, very soon
Mirjam’s last blog post..Dilemma of a Blogger Follow Up
I plan to add “random posts” to the header image… And, that will be very soon…
Thanks for hearing the request and coming up with the how-to, so soon. Good job!
–Inspirit
Abhinav Sood’s last blog post..What is Sitemap? Why and How to add a Sitemap to your Blog or Website?
Abhinav, what value do you think random posts page will get you?
Do you mean it would be a random post link, that once clicked would bring you to a random article?
Great site. Get your self some banners from cj to make extra $:)