View Single Post
  #1 (permalink)  
Old 06-14-07, 04:11 AM
manuleka's Avatar
manuleka manuleka is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
padding error, div within div

ok i've got a block of div which contains another div within!
its floated to the right of my webpage.... here's the codes

style:
css Code:
  1. div.recent_proj{
  2.     background-color:#b0b0b0;
  3.     width:150px;
  4.     position:relative;
  5.     float:right;
  6.     margin-right:10px;
  7.     margin-left:10px;
  8.     border:1px dashed #606060;
  9.     text-align:center;
  10.     color:#000000;
  11.     font-family:tahoma,verdana,arial;
  12.     font-size:11px;
  13.     font-weight:bold;
  14.     }
  15.  
  16. div.recent_proj div{
  17.     position:relative;
  18.     width:100%;
  19.     margin:auto;
  20.     padding:5px;
  21.     background-color:#e0e0e0;
  22.     }
  23. div.recent_proj div a:link, a:visited{
  24.     color:blue;
  25.     font-weight:normal;
  26.     text-decoration:none;
  27.     }
  28. div.recent_proj div a:hover{
  29.     color:red;
  30.     }

html:
HTML Code:
<div id="r_proj" class="recent_proj">
	<br />Recent Projects<br /><br />
		<div>
			<a href="">Site Number 1:<br />
			Fill this space up with
			your site by clicking here!</a><br /><br />
			<a href="">Site Number 2:<br />
			Fill this space up with
			your site by clicking here!</a><br /><br />
			<a href="">Site Number 3:<br />
			Fill this space up with
			your site by clicking here!</a><br /><br />
			<a href="">Site Number 4:<br />
			Fill this space up with
			your site by clicking here!</a><br /><br />
		</div>
</div>
now what i get is that the inner div overlaps the outer/parent div when i add in the padding:5px on the div.recent_proj div

why is this happening? i was expecting the child div to only go as far as the 150px width of the parent div unless i insert picture or something wider than 150px!

can anyone enlighten me please

Last edited by Nico; 06-14-07 at 04:17 AM. Reason: Please use [highlight=css] and [html] wrappers.
Reply With Quote