• 0

DIV width not filling containing element


Question

I have set 'rowmain' to 740px and 'leftcolumn' & 'rightcolumn' to 370. But 'leftcolumn' & 'rightcolumn' are 1 pixel shorter than rowmain. I have tried almost everything no borders, no margins & no paddings. But still the width is 1 pixel shorter than it should be and it is driving me crazy.

So I want to know why these two divs are 1 pixel shorter than they should be!

<div id="rowmain">
	<div id="leftcolumn" class="data">content1</div>
	<div id="rightcolumn" class="data">content2</div>
</div>

Thanks

4 answers to this question

Recommended Posts

  • 0
#rowmain {
	width: 740px;
	height: 500px;
	border: #88add7 0px solid;
	clear: both;
	position: relative;
	display: block;
}

#leftcolumn {
	width: 350px;
	height: 500px;
	border: #88add7 1px solid;
	padding: 10px;
	position: relative;
	display: block;
	float: left;
}
#rightcolumn {
	width: 350px;
	height: 500px;
	border: #88add7 1px solid;
	position: relative;
	display: block;
	padding: 10px;
	float: left;;
	border-left: #88add7 0px solid;
}

  • 0

The problem seems to arise when you apply border-left: #88add7 0px solid; to #rightcolumn. It's not actually a problem, its just that you are probably forgetting to factor it in to your calculations.

leftcolumn = 350px width + 20px padding (10px for left and right) + 2px border (1px for left and right) = 372px wide

right column = 350px width + 20px padding (10px for left and right) + 1px border (1px for right, left is 0) = 371px wide

372px + 371px = 743px

So your rowmain should be 743px wide and everything will be nice and snug ;)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.