Switching which float loads first

Discussion in 'CSS' started by astralis, Feb 21, 2006.

  1. #1
    I have a two divs, one that is variable text and the other that is a float and resides in the top right of the first div.

    But the problem with this is that the floating div must appear at the top of the code or else it will appear at the bottom. This is not good for me because that float contains the menu and the other div contains the body text. For the search engines I want to reverse this. Can it be done?
    
    <div>
    <div style="float:right">
    menu text
    </div>
    Body text.  I want this to go above the floating div.
    </div>
    Code (markup):

     
    astralis, Feb 21, 2006 IP
  2. FeelLikeANut

    FeelLikeANut Peon

    Messages:
    330
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Instead of floating the menu to the right, float the body text to the left.
     
    FeelLikeANut, Feb 21, 2006 IP
    astralis likes this.
  3. astralis

    astralis Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    First, thanks for assisting.

    I tried floating the body text to the left but it didn't like that and placed it above the menu I then made both a float left and float right but the margin on the right doesn't work right.

    Try both of these and please tell me what I'm doing wrong.
    
    <div>
    <div style="float:left; border:1px solid #000;">
    Body text.  I want this to go above the floating div.
    <div style="float:right; margin:0; border:1px solid #000;">menu text
    </div>
    </div>
    </div>
    
    Code (markup):
    
    <div>
    <div style="float:left; border:1px solid #000;">
    Body text.  I want this to go above the floating div.
    <div style="margin:0; border:1px solid #000;">menu text
    </div>
    </div>
    </div>
    
    Code (markup):
     
    astralis, Feb 21, 2006 IP
  4. FeelLikeANut

    FeelLikeANut Peon

    Messages:
    330
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Your menu DIV is nested within the body text DIV. So your menu stays with the body text when it gets floated.
    <div style="float:left; background-color: rgb(245,255,245); width: 410px">
      <p>Body text. I want this to go above the floating div.</p>
    </div>
    
    <div style="margin-left: 410px; background-color: rgb(255,245,245); width: 150px">
      <p>menu text</p>
    </div>
    Code (markup):
    Note, it seems IE will need a margin-left of 411px, instead of the correct 410px.
     
    FeelLikeANut, Feb 21, 2006 IP
  5. astralis

    astralis Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks! I've taken a look at this and think it's the best choice. I wanted the body text to be variable to the size of the window, but with CSS I do not believe that is possible while having a fixed-width float as well - if I want to have the body text at the top of the html for the search engines.
     
    astralis, Feb 21, 2006 IP