Headings floating left and right

This is a discussion on "Headings floating left and right" within the Starting Out section. This forum, and the thread "Headings floating left and right are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Starting Out

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jul 21st, 2007, 16:44
Reputable Member
Join Date: Jul 2007
Location: UK
Posts: 115
Thanks: 2
Thanked 1 Time in 1 Post
Headings floating left and right

Hi!

I'm having a bit of trouble getting my floats to float in the right place. I have the following in HTML:

Code: Select all
<div id="header">
     
    <div id="headings">
        <h1>Nature photography in Yorkshire</h1>
         <h2>by Jonathan Mortimer</h2>
         
     </div>
     
 </div>
and this in my stylesheet:
Code: Select all
#header {
    width:900px;
    background: url(../images/cloudscape_banner.jpg) no-repeat top left;
    height: 120px;
    }   
    
#headings {
    width:900px;
    background: url(../images/ladybirds_cone.png) no-repeat bottom left;
    height: 120px;
    }     

#headings h1 {
    font: 32pt helvetica;
    color: #ffffcc;
    float: right;
    /* margin-left: 220px; */
    margin-right: 26px;
    margin-top: 10px;
    margin-bottom: 0px;
    text-shadow: black 2px 3px 2px;

    }
    
#headings h2 {
    font: italic normal 18pt helvetica;
    color: #ffffcc;
    float: right;
    margin-right: 30px;
    margin-top: 8px;    
    text-shadow: black 2px 3px 2px;

    }
Now for some odd reason the H2 subheading "by Jonathan Mortimer" floats to the top left in Firefox, but is OK in Safari. I've tried juggling them around but nothing seems to work. Any clues as to what's going on? This was working fine until very recently, can't remember what I did to make it go wobbly but I certainly wasn't working on the headings at the time
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jul 21st, 2007, 17:30
Elite Veteran
Join Date: Sep 2006
Location: Pink House
Posts: 3,946
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Headings floating left and right

Add a clear: both; to the h2!
Code: Select all
#headings h2 {
    font: italic normal 18pt helvetica;
    color: #ffffcc;
    float: right;
    margin-right: 30px;
    margin-top: 8px;
    text-shadow: black 2px 3px 2px;
    clear: both;
    }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jul 21st, 2007, 17:33
Reputable Member
Join Date: Jul 2007
Location: UK
Posts: 115
Thanks: 2
Thanked 1 Time in 1 Post
Re: Headings floating left and right

Quote:
Originally Posted by Lchad View Post
Add a clear: both; to the h2!
Wow thanks, that did the trick! Care to explain how that works or is it too complicated? Sometimes I get the feeling I may never understand these things, just code blind until something works
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jul 21st, 2007, 17:45
Elite Veteran
Join Date: Sep 2006
Location: Pink House
Posts: 3,946
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Headings floating left and right

Sure I'll see if I can explain it.
The float property moves an element left or right. (In your case.. right). In the process, content below the float will move up and wrap around the float. So the next thing under the float will fill in the empty space ON THE LEFT.
If you put a clear: both; it's almost as if you have placed an imaginery line under the first float:right. The imaginery line fills up the entire width of the container, in this case headers.

header
------------------------------
header

If you float something to the left, it leaves empty space on the right.

To stop a float you use clear. The clear property tells an element not to wrap around a floated item. By clearning you force the next element below.

A clear left will drop below elements that are floated left but will still wrap around the right.

A clear right will drop below elements that are floated right but will still wrap around the left.

A clear both drops the element below both left and right floated elements.

So technically you could use clear: right;
but I told you clear: both; because I can never remember and I didn't want to take a chance!

Totally confused now?

EDIT: The words headers in the diagram should be moved over to the right but I can't make them move...darn..

Last edited by Lchad; Jul 21st, 2007 at 17:46. Reason: fix spacing of words header
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jul 21st, 2007, 18:35
Reputable Member
Join Date: Jul 2007
Location: UK
Posts: 115
Thanks: 2
Thanked 1 Time in 1 Post
Re: Headings floating left and right

Quote:
Originally Posted by Lchad View Post
Sure I'll see if I can explain it.
...
Totally confused now?
By golly I think I actually understood most of that!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Jul 21st, 2007, 22:27
Elite Veteran
Join Date: Sep 2006
Location: Pink House
Posts: 3,946
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Headings floating left and right

Way to go Jonny!
Isn't it addictive?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
heading float

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Headings H1 &amp; 2 appear too big on my web pages? Oak Web Page Design 2 Dec 26th, 2007 00:11
Mozilla floating my div to the left and not Center erikkl2000 Web Page Design 5 Jan 5th, 2007 19:41
Floating <hr>s to the left/IE problems... escaflowne11 Web Page Design 5 Oct 15th, 2006 21:34
Floating Without tables jcschott Web Page Design 3 Apr 19th, 2005 16:22
Table Column Headings and Page Breaks Trebz Web Page Design 8 Jun 4th, 2004 12:55


All times are GMT. The time now is 21:18.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42