Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-29-2011, 10:23 AM   PM User | #1
eaglei22
New to the CF scene

 
Join Date: Apr 2011
Posts: 5
Thanks: 3
Thanked 0 Times in 0 Posts
eaglei22 is an unknown quantity at this point
Absolute positioning of a Div inside a Div

I have my Div's with a margin: 0px auto; to compensate for wider monitors. Problem is, I want to position another div inside one of these divs but when I do absolute positioning, it keeps doing it from the upper left of the browser. How do I get it to position from the the upper left corner of the Div it is inside?

Here is my code inside my css stylesheet:

Code:
#header {
  width: 800px;
  height: 70px;
  margin:0px auto;
  text-align:left;
  background-color:#fff;
}


#insideheader {
   position: absolute;
   top:   20px;
   left:  720px;
   width: 175px;
   height: 30px;
   text-align:left;
   background-color:#fff;
}
And here is my code from the html:

Code:
<div id="header">
  <img src="Graphics/Smaller title.png">
  <div id="insideheader">
    <table align = "center">
      <tr>
        <td><font size="2" font color="gray">Terms Of Use</font></td>
        <td></td>
        <td class="leftedge2"></td>
        <td><font size="2" font color="gray">Contact Us</font></td>
      </tr>
   </table>
  </div>
</div>
What am I doing wrong? Or what should I be doing differently?

Thanks!!
eaglei22 is offline   Reply With Quote
Old 04-29-2011, 10:34 AM   PM User | #2
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
set position: relative; on the outer div and position: absolute on the inner div. The top and left styles on the inner div will then be relative to the top left hand corner of the outer div.
bullant is offline   Reply With Quote
Users who have thanked bullant for this post:
eaglei22 (04-29-2011)
Old 04-29-2011, 10:36 AM   PM User | #3
eaglei22
New to the CF scene

 
Join Date: Apr 2011
Posts: 5
Thanks: 3
Thanked 0 Times in 0 Posts
eaglei22 is an unknown quantity at this point
Thanks a bunch! Worked like a charm.
eaglei22 is offline   Reply With Quote
Old 04-29-2011, 10:37 AM   PM User | #4
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
you're welcome
bullant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:25 PM.


Advertisement
Log in to turn off these ads.