Jump to content

CSS Float Problem


lostprophetpunk

Recommended Posts

I have a box which contains four divs...

 

lowboxc

lowboxtop

lowboxmain

lowboxbottom

 

I then have another box inside with four divs...

 

testc

testtop

testmain

testbottom

 

I am trying to get three of the 'test' divs inside the 'lowbox' div so that there are three of them, one for the left, one in the middle and then one on the right.

 

I can get the left and middle ones working by using 'float:left' and 'margin:auto', but when I use the 'float:right' property on the last one, then the last one does float to the right, but displays underneath the other boxes.

 

The total width of the boxes should fit in the width of the lowbox, so why isn't it working?

 

This is the css for the divs mentioned above...

#lowboxc {
  width: 660px;
  margin: auto;
}

#lowboxtop {
  margin-top: 10px;
  width: 650px;
  height: 30px;
  background: transparent url(images/lowboxtop.png) no-repeat center center;
  font-family: "trebuchet ms", sans-serif;
  font-size: 18pt;
  font-weight: bold;
  color: #000000;
  padding-left: 10px;
  padding-top: 10px;
}

#lowboxmain {
  width: 660px;
  height: auto;
  background-color: #bf003a;
}

#lowboxbottom {
  width: 660px;
  height: 30px;
  background: transparent url(images/lowboxbottom.png) no-repeat center center;
}

.testc {
  width: 170px;
}

.testtop {
  width: 170px;
  height: 20px;
  background: transparent url(images/testtop.png) no-repeat center center;
}

.testmain {
  width: 150px;
  height: auto;
  padding-left: 10px;
  padding-right: 10px;
  font-family: "trebuchet ms", sans-serif;
  font-size: 9pt;
  font-weight: bold;
  font-style: italic;
  color: #ffffff;
}

.testbottom {
  width: 170px;
  height: 20px;
  background: transparent url(images/tesbottom.png) no-repeat center center;
}

 

Here is the html for those divs...

  <div id='lowboxc'>
   <div id='lowboxtop'>Testimonials</div>
    <div id='lowboxmain'>
      <div class='testc' style='float:left;'>
        <div class='testtop'></div>
          <div class='testmain'>
           Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam eleifend, arcu at condimentum faucibus, urna nulla vehicula lectus, ut suscipit quam nisi euismod elit. Vestibulum massa dolor, venenatis ac, malesuada eu, aliquet sed, dui. Donec at nibh.
          </div>
        <div class='testbottom'></div>
      </div>
      <div class='testc' style='margin: auto;'>
        <div class='testtop'></div>
          <div class='testmain'>
           Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam eleifend, arcu at condimentum faucibus, urna nulla vehicula lectus, ut suscipit quam nisi euismod elit. Vestibulum massa dolor, venenatis ac, malesuada eu, aliquet sed, dui. Donec at nibh.
          </div>
        <div class='testbottom'></div>
      </div>
      <div class='testc' style='float:right;'>
        <div class='testtop'></div>
          <div class='testmain'>
           Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam eleifend, arcu at condimentum faucibus, urna nulla vehicula lectus, ut suscipit quam nisi euismod elit. Vestibulum massa dolor, venenatis ac, malesuada eu, aliquet sed, dui. Donec at nibh.
          </div>
        <div class='testbottom'></div>
      </div>

Link to comment
Share on other sites

try floating all three testc divs to the left.

 

If you had a link, it would be much easier to help. Got one?

I haven't got a link, as I am coding it offline. I have aligned the first two divs to float left, that makes the divs align horizontally, but then it breaks out of the lowbox div.

 

Maybe this picture will help you out a bit more.

Link to comment
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.