Jump to content

Divs lining up with each other


coldkill
 Share

Recommended Posts

Hey folks,

another problem has come up with a new site I'm developing. I'm trying to get two divs to be in line with each other, I've tried using display: inline; to no avail, in fact it came up with a lot of errors in both IE and FX.

 

Any ideas what I can do?

 

Cold

Link to comment
Share on other sites

If using inline, it's very similar to using inline for list items with DIVs instead, and you will have to use margin or padding to space them out. Maybe instead float the first div left and specify width for both DIVs. Depends on what you're trying to do.

Link to comment
Share on other sites

When I try to make two divs inline I do something like this (not tested). The basics are I set the width for both divs. I float the left (or right) div and use clear:both afterwards so nothing gets caught in the float. Works perfect everytime (with a bit o' tweaking of course).

 

<style type="text/css">
  #a {
    float:left;
    width:200px;
    background:green;
  }

  #b {
    width:200px;
    background:red;
  }

  .clear {
    clear:both;
  }
</style>

 

<html>
  <div id="a">left content</div>
  <div id="b">right content</div>
  <div class="clear"></div>
</html>

Link to comment
Share on other sites

Ok, here's the code that is applicable:

 

<div id="content_wrap">
		<div id="providers">
			<div class="header">Powered By</div>
Images here
		</div>

		<div id="content">
Stuff here
		</div>
	</div>

 

#content_wrap
{
width: 900px;
padding: 10px 0px 10px 0px;
}

#content
{
width: 740px;
margin-left: 140px;
border: 1px solid #CCCCCC;
padding: 0px 10px 0px 10px;

}

.header
{
padding: 2px 0px 2px 0px;
background-image: url(images/header_background.jpg);
background-repeat: repeat-x;
color: #FFFFFF;
font-weight: bold;
text-align: center;
}


/*
*	Providers
*/
#providers
{
width: 120px;
border: 1px solid #CCCCCC;
}

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.