Connecting Tech Pros Worldwide Forums | Help | Site Map

align div at the bottom of another div

Member
 
Join Date: Oct 2007
Posts: 107
#1: Apr 29 '09
hi everybody,

i want to align a div at the bottom but inside the div. here is the code:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <style type="text/css">
  7. <!--
  8. #header {
  9.     background-color: #006;
  10.     width: 780px;
  11.     margin-top: 0px;
  12.     margin-right: auto;
  13.     margin-bottom: 0px;
  14.     margin-left: auto;
  15.     height: 200px;
  16. }
  17. #navbars {
  18.     background-color: #999;
  19.     height: 50px;
  20.     width: 450px;
  21.     overflow: auto;
  22. }
  23. -->
  24. </style>
  25. </head>
  26.  
  27. <body>
  28. <div id="header">
  29.   <div id="navbars"></div>
  30. </div>
  31.  
  32. </body>
  33. </html>
  34.  
The div wit the id "navbars" needs to be aligned at the center bottom inside the div bottom header. please tell me how i can do this using css.

thanx

Newbie
 
Join Date: Apr 2009
Posts: 1
#2: May 6 '09

re: align div at the bottom of another div


use position:relative for Heder id and position:absolute for navbars.
the code will be as ffollow:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#header {
background-color:#000066;
height:200px;
margin:0 auto;
position:relative;
width:780px;
}
#navbars {
background-color:#999999;
bottom:0;
height:50px;
overflow:auto;
position:absolute;
width:450px;
}
-->
</style>
</head>

<body>
<div id="header">
<div id="navbars"></div>
</div>

</body>
</html>
Reply