How to put float:right DIVS into the center of the page?!

Discussion in 'CSS' started by redhits, May 31, 2010.

  1. #1
    How i can align float:right DIVs into the middle of the page?
    I can't put them into an 40% or 60% div because the number of DIVs will be generate by a dynamic PHP file.


    Until now i have the code:
    
    .infobox {
          width:250px; height:250px;
          background-image:url('images/infoboxbg.gif');
          float:left;  
    } 
    .infospace {
          width:20px; height:250px;   float:left; margin:0 auto;
          } 
    .infotext {
          font-size:12px; font-family:Verdana; color:#333; text-align:left; width:230px; padding-left:10px; height:190px;  padding-top:3px;
          } 
    .infotitle {  
          margin:0 auto; text-align:center;  width:230px; padding-top:6px; padding-bottom:3px;
          font-size:15px; font-family:Verdana;  border-bottom:2px #aaa dotted;
          }       
    </style>
    
    Code (markup):

    ....

    and doing something like:
    
    <div class=infospace></div>
    <div class=infobox>
    <div class=infotitle><b><font color=red>Yahoo problem!</font></b></div>
    <div class=infotext>You are dropping in serps in Yahoo</div>
    <div class=infotype><img src="images/alert_warning.gif"></div>
    </div>
    <div class=infospace></div>
    <div class=infobox>
    <div class=infotitle><b><font color=red>Google problem!</font></b></div>
    <div class=infotext>You are dropping in serps in Google</div>
    <div class=infotype><img src="images/alert_warning.gif"></div>
    </div>
    <div class=infospace></div>
    <div class=infobox>
    <div class=infotitle><b><font color=red>MSN problem!</font></b></div>
    <div class=infotext>You are dropping in serps in MSN</div>
    <div class=infotype><img src="images/alert_warning.gif"></div>
    </div>
    
    Code (markup):
    will only float all divs to left...i don't want to put them all to left, i want to align them on the same line, and put them in the middle... without float they will be aligned on of the top of each other :(
     
    redhits, May 31, 2010 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    No problem, just search for a dynamic centering tutorial, like this one:
    Horizontally centering content with dynamic width in CSS

    Wrap your content with an extra div that has these properties:
    .infowrap { display: table; margin: 0 auto; }

    Like the tutorial says, it works in all browsers that recognize display: table, which does not include IE6 or IE7 unfortunately.
     
    Cash Nebula, Jun 1, 2010 IP
  3. unigogo

    unigogo Peon

    Messages:
    286
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hard to understand what you want
     
    unigogo, Jun 3, 2010 IP
  4. redhits

    redhits Notable Member

    Messages:
    3,023
    Likes Received:
    277
    Best Answers:
    0
    Trophy Points:
    255
    #4
    I wanted to do what Cash Nebula told me :)
     
    redhits, Jun 4, 2010 IP