Jump to content

Recommended Posts

I have three divs that float.  They all have the same properties besides the floating part:

 

            margin-top: 100px;

width: 200px;

padding: 10px;

 

Here is the problem.  I float the first box left.  In my source (CSS and xhtml both validated), I print the boxes 1, 2, 3.  The second two boxes are floating right.  So, based on the rule that no right floated element can be placed further to the right than one in the previous source, I am expecting this order:

 

1, 2, 3.

 

But, I get this order:

 

1, 3, 2

 

But if I float the second box left, it appears 1, 2, 3.  Can anybody help me figure this out or point out where I am missing something?  All necessary code is below. 

 


*.formbackground { 
background-color : rgb(255, 250, 170);
border-style: solid;
border-width : 2px;
border-color : red;

} 

div#accountSummary
{
margin-top: 100px;
float: left;
width: 200px;
padding: 10px;


}

div#personalInfo
{
margin-top: 100px;
float: right;
width: 200px;
padding: 10px;


}

div#imageCenterSmall
{
margin-top: 100px;
float: right;
width: 200px;
padding: 10px;


}

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="shop.css" media="all" />
</head>
<body>
<div class="formbackground" id="accountSummary">box 1</div>
<div class="formbackground" id="personalInfo">box 2</div>
<div class="formbackground" id="imageCenterSmall">box 3--why is this in the middle?</div></body>
</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/64509-solved-floating-issue/
Share on other sites

Think of it this way-box 2 is the one that is being floated right FIRST in order of the code, and box three is being floated after box 1, meaning that it ends up in the middle. To see more clearly what happens when code is floated right, make an <ol> element and have all the <li>'s floated right-that's a clear demonstration of this property at work.

Link to comment
https://forums.phpfreaks.com/topic/64509-solved-floating-issue/#findComment-321583
Share on other sites

Okay, I wrote out that example, and I see what you mean--it appears backwards.  BUT, why isn't that against the rules?  The browser is floating an element earlier in the source farther to the right.  ???

 

Also, is it normal for the list marker to go away like that?  And, if I copy/paste, it appears in the correct order on the paste!

 

 

Link to comment
https://forums.phpfreaks.com/topic/64509-solved-floating-issue/#findComment-321772
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.