473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

assorted misbehaviours around float: left

I've a very simple page (intranet, but moved to
http://services.ccagroup.co.uk/dtest.html for you - so the links are all
broken).

essentially it's just a list of links.

I've split it into two columns with a floated left div, and therein lie
the problems.

It's valid 4.01 strict, but none of ie, moz, or ff correctly offset the
right div - it overlaps the longest line on the left (CCA External Web
Site Statistics Reports).

On moz & ff, fortuitous indentation on the right prevents actual
overlaying of text; but they have a spurious linefeed at the top of the
left div.

ie doen't have the linefeed, but doesn't do any sublist indentation on
the right for some reason, so the text is overprinted.

Have I done something stupid, or does this page really demonstrate
multiple bugs in all major browsers ?

I originally had one master <ul> with the left & right divs inside it,
but I suspected that was illegal, so I made it one <ul> in each div.

As I say, I've moved the page to the www for you to see, so I know about
the broken links.

Thanks
Chris
Jul 21 '05 #1
4 2859
Chris Sharman wrote:
I've a very simple page (intranet, but moved to
http://services.ccagroup.co.uk/dtest.html for you - so the links are all
broken).

essentially it's just a list of links.

I've split it into two columns with a floated left div, and therein lie
the problems.

It's valid 4.01 strict, but none of ie, moz, or ff correctly offset the
right div - it overlaps the longest line on the left (CCA External Web
Site Statistics Reports).

On moz & ff, fortuitous indentation on the right prevents actual
overlaying of text; but they have a spurious linefeed at the top of the
left div.

ie doen't have the linefeed, but doesn't do any sublist indentation on
the right for some reason, so the text is overprinted.

Have I done something stupid, or does this page really demonstrate
multiple bugs in all major browsers ?

I originally had one master <ul> with the left & right divs inside it,
but I suspected that was illegal, so I made it one <ul> in each div.

As I say, I've moved the page to the www for you to see, so I know about
the broken links.
Yet to master follow-ups. Sorry.
Thanks
Chris

Jul 21 '05 #2
Danny@Kendal wrote:
"Chris Sharman" <ch***********@sorry.nospam> wrote in message
I've a very simple page (intranet, but moved to
http://services.ccagroup.co.uk/dtest.html for you - so the links are all
broken).

I've split it into two columns with a floated left div, and therein lie
the problems.
Float *both* main <div> elements.


Thanks - that fixes it (although I now get the extra blank line at the
top of both divs).
But why ?
I thought a straight unstyled div should just abut the existing floated
left div, if there's room ?
Add style="clear:both" to the third <div> element if you want it to appear beneath them.


Yes, better, and necessary now the second's floating too.
Posted at dtest2.html.

Thanks,
Chris
Jul 21 '05 #3
Chris Sharman wrote:
Danny@Kendal wrote:
"Chris Sharman" <ch***********@sorry.nospam> wrote in message
I've a very simple page (intranet, but moved to
http://services.ccagroup.co.uk/dtest.html for you - so the links are all
broken).

I've split it into two columns with a floated left div, and therein lie
the problems.

Float *both* main <div> elements.

Thanks - that fixes it (although I now get the extra blank line at the
top of both divs).
But why ?
I thought a straight unstyled div should just abut the existing floated
left div, if there's room ?
> Add style="clear:both" to the third <div> element if you want it to

appear
> beneath them.


Yes, better, and necessary now the second's floating too.
Posted at dtest2.html.


In your page, the best method to render in Moz/FF and IE alike is
probably to float:left; both divs as suggested with a clear:left; on the
following HR element.
Place borders around your divs to see that the margins are coming from
H2's margin-bottom and from UL's margin-top. Alter them as needed.

Here is an explanation of what was happening in your code.
Moz/FF follow the rules but not IE.

The left div is floated, so is out of the flow and sets at the point of
H2's margin-bottom.
The right div has a margin-top just as H2 has a margin-bottom and they
are collapsed whereby the smallest value is dropped. Hence the
difference of points of reference for the two divs.

The three solutions are:
1. Set H2's margin-bottom to zero to abut the H2 and float boxes, or
2. Add a border to the right div to prevent H2's margin-bottom
and the right div's margin-top from collapsing, or
3. Add padding-top to the right div to prevent H2's margin-bottom
and the right div's margin-top from collapsing.

Also add margin-left:300px; to the right div in order to clear the
list markers which are outside of the box.
Another thing is that IE doesn't do things right, so not the same.

--
Gus
Jul 21 '05 #4
Gus Richter wrote:
Place borders around your divs to see that the margins are coming from
H2's margin-bottom and from UL's margin-top. Alter them as needed.

Here is an explanation of what was happening in your code.
Moz/FF follow the rules but not IE.

The left div is floated, so is out of the flow and sets at the point of
H2's margin-bottom.
The right div has a margin-top just as H2 has a margin-bottom and they
are collapsed whereby the smallest value is dropped. Hence the
difference of points of reference for the two divs.


Now I get it - thanks very much

Chris
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Suzanne Boyle | last post by:
I have the following code in a webpage: <p><img src="images/clydesdale.gif" width="100" height="41" style="float: left;" /> <strong>Test</strong><br /> Lorem ipsum dolor sit amet, consetetur...
9
by: steven | last post by:
Hi, I can float the image left or right so the text will float around it, but only if the top of the image is aligned with the start of the paragraph. I'd like the image be a little below that, so...
2
by: mike | last post by:
Hello, What I would like is to float some text around the image where the text starts align on the left or right of the image aligned to the top of the image and then wrap around the image. I have...
10
by: Dan V. | last post by:
Is it possible to have 2 divs beside each other and one not wrap around? I realize the 2 div's are floating left but I can only think of this as the best solution for now. I am trying to get...
8
by: V.Ch. | last post by:
In near future I can face a prospect of writing some stuff in C. Being a C++ programmer, I've got practically no experience in C. I'd be obliged if someone could answer the following questions...
0
by: jonipony | last post by:
HELP: Float Left box is drifting to the right in ie! -------------------------- I need som HELP with my CSS coding! On the following web page my design falls apart at screen size 800 x 600...
14
by: Zhang Weiwu | last post by:
Hello. I have been using word processor like OOO for nearly 10 years and such layout is very usual to me: gopher://sdf.lonestar.org/I/users/weiwu/ooo_wrap_correctly.png but I found it's very...
8
by: Jonathan Sachs | last post by:
I'm trying to compose a list of items, each of which consists of text that wraps around a picture at the left margin. The examples I have seen tell me to do it like this: <p><img src="xxxx.jpg"...
5
by: Gozil | last post by:
Hey, Is it possible to change line on a float object? For example let say I have one <b> tag, one <p> tag and one <img> tag: I want the <img> to have float right and the <b> to have float left...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.