written on:16 Sep, 2007 by Alen Grakalic
Floater
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed

Here's a simple little trick on how to have make secondary content float to the right of the title. You can use this for variety of purposes like put an icon to rss feed or link to full article. View example page to get an idea :).
Why should this make any sense?
Usually when putting floated content, developers put it BEFORE the element in the flow. i.e. images before paragraphs. When it comes to titles (and we all use heading tags for that right? :) ) the situation is a tiny bit different. Title should represent the beginning of the section and anything related to it should come AFTER it in the markup structure. So "click for full story" links should be below the title not above it.
Markup and CSS
So, the markup should look like this.
<h2>Blog post</h2>
<p class="floater"><a href="#">more...</a></p>
<p>blog summary text</p>
In this example I am using a link to full article next to a blog post title. Sure, it would make more sense to put a link to full story after summary, but we are trying to achieve certain effect, and this trick can be used for different things.
Ok, so here goes... The trick is add float:right and apply negative top margin to the floater. That will move it to the right and to the top in the title area.
.floater {
margin:0;
float:right;
margin-top:-3em;}
The value of negative top margin depends on title height and floater content height so you'll need to adjust that.
To make it bulletproof use fixed values like:
h2 {
height:24px;
line-height:24px;}
.floater {
margin:0;
float:right;
margin-top:-24px;
height:24px;
line-height:24px;}
Since we removed floater from the flow, any content that comes after it acts like it comes directly after the title. This is merely the basis. Depending on other elements, like title length, you will have to make adjustments so the elements don't interfere with each other.
Examples
I suggest to look at the examples to see where I am getting at with this. Download them and apply to your designs.
About the author:
Designer, developer and a passionate standardista with large experience in all types of front-end work. Started to get involved with web in 1999. and turned freelance in 2005., the same year he started Css Globe. Alen's work has been featured on numerous css galleries including famous Css Zen Garden official list. Available for contract work.
Enjoyed the article?
Subscribe to our RSS feed or share it with your friends.
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed
Comments
Subscribe
Join 5000+ subscribers and receive our content instantly.
Follow us on Twitter
Want to be the first to know when a new article is published?
Sponsors

Look Professional with FreshBooks

Sitegrinder 2 Photoshop Plugin
Recent Articles
- Purist or a Freak
- CSS do's and dont's Part 2- Markup
- Easiest Tooltip and Image Preview Using jQuery
- 4 Uber Cool Css Techniques For Links
- CSS do's and dont's Part 1: CSS Selecting




Marko on 17 Sep, 2007 wrote:
Stuart on 17 Sep, 2007 wrote:
david b on 17 Sep, 2007 wrote:
cssglobe on 17 Sep, 2007 wrote:
Fredrik Wärnsberg on 17 Sep, 2007 wrote:
cssglobe on 17 Sep, 2007 wrote:
Fredrik Wärnsberg on 17 Sep, 2007 wrote:
Fredrik Wärnsberg on 17 Sep, 2007 wrote:
(sorry for the double comment, feel free to move this bit up to the last comment).
cssglobe on 17 Sep, 2007 wrote:
Katie on 21 Sep, 2007 wrote:
PiticStyle on 21 Sep, 2007 wrote:
myaleigh on 26 Sep, 2007 wrote:
Reynder on 2 Oct, 2007 wrote:
to place an ? Why not use the to place it's self?
tomo on 4 Oct, 2007 wrote:
Dejan on 3 Jan, 2008 wrote:
ghasem on 16 Feb, 2008 wrote:
SEO Bedrijven on 28 Apr, 2008 wrote: