
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.
Marko 17 Sep, 2007
Stuart 17 Sep, 2007
david b 17 Sep, 2007
cssglobe 17 Sep, 2007
Fredrik Wärnsberg 17 Sep, 2007
cssglobe 17 Sep, 2007
Fredrik Wärnsberg 17 Sep, 2007
Fredrik Wärnsberg 17 Sep, 2007
(sorry for the double comment, feel free to move this bit up to the last comment).
cssglobe 17 Sep, 2007
Katie 21 Sep, 2007
PiticStyle 21 Sep, 2007
myaleigh 26 Sep, 2007
Reynder 2 Oct, 2007
tomo 4 Oct, 2007
Dejan 3 Jan, 2008
ghasem 16 Feb, 2008
SEO Bedrijven 28 Apr, 2008