css float problem

This is a discussion on "css float problem" within the Starting Out section. This forum, and the thread "css float problem are both part of the Design Your Website category.



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

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 5th, 2007, 09:47
Junior Member
Join Date: Mar 2007
Location: Wilts, UK
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Red face css float problem

Hello again, I'm having another headache!

I am trying to float images within a div containing the image (left) and a paragraph of text to the right. However the bottom border of the container div ends after the text, I can't get it to extend below the image if the paragraph is short http://www.northwiltsholidayclub.org.uk/havingfun.html

I don't really want the text going under the images where the paragraph is long either - how can I achieve a simple box with image on one side and text on the other?

I want to float some divs containing text on my home page as well but that does the same thing,as soon as I add the float the bottom border of the containing div reverts upwards. http://www.northwiltsholidayclub.org...ghomepage.html

I feel it would be better to have the content first in the html (before the right column ads) but I can't work out whether this is possible because I also want the content column to be fluid width.

Sorry this is so basic - as I've mentioned elsewhere in these forums my knowledge is from internet tutorials etc and is full of holes, and this is my first try. Any help much appreciated.

Now I've realised I have put this in the wrong place and I can't move it, sorry! I'll try again in the right place (ie complete beginners), so moderators please remove this when you find it.

Last edited by milly; Jul 5th, 2007 at 11:29. Reason: I'm an idiot
Reply With Quote

  #2 (permalink)  
Old Jul 5th, 2007, 11:37
Up'n'Coming Member
Join Date: Jun 2007
Location: Birmingham, UK
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Re: css float problem

To make container div extend below all floating elements in the div you have to add an extra div which clears all the floats.
Code: Select all
<div class="container">
  <!-- content and floating elements here -->
  <div style="clear:both;"></div>
</div>
To avoid the text going under the image, also place it inside a floating div.
Reply With Quote
  #3 (permalink)  
Old Jul 5th, 2007, 12:24
SuperMember

SuperMember
Join Date: Sep 2006
Location: Pink House
Posts: 3,946
Thanks: 0
Thanked 0 Times in 0 Posts
Re: css float problem

A Solution that I have used for this exact problem is to give the image a large margin-bottom

100px or whatever you need. That will fill up that space on the left under the image, force the div down and keep the text on the right.
Reply With Quote
  #4 (permalink)  
Old Jul 9th, 2007, 02:51
Junior Member
Join Date: Mar 2007
Location: Wilts, UK
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Re: css float problem

Many thanks - solved with the clearance div and double floaters!
Reply With Quote
Reply

Tags
css, div, float, nested

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
Float problem with Firefox Emzi Web Page Design 10 Apr 4th, 2008 12:02
CSS float problem Advanced Kropotkin Web Page Design 7 Aug 15th, 2007 16:21
right float problem... c_martini Web Page Design 11 Aug 2nd, 2006 13:47
Image float problem timmytots Web Page Design 6 Jul 8th, 2006 13:40
site ok in Firefox, not in IE : float problem?? bbbobo Web Page Design 1 Sep 30th, 2005 08:16


All times are GMT. The time now is 12:44.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs 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 43