tags:

views:

39

answers:

2

Hi I am having trouble getting a div to stay in place when the window is resized. It overlaps the content div when its made smaller.

#content
{
  width: 70%; 
  height: 800px;    
  margin-top: 50px;     
  margin-left: auto;
  margin-right: auto;
  background-color: #202020;
  padding: 30px;        
}

#login
{
  float: right;
  margin-right: 20px;
  margin-top: 50px;
  background-color: #4A4344;
  width: 200px;
  height: 220px;
  text-align: center;       
}

It's easier if I give a link for you to see yourself: Link

I tried to set the values to em and percentages but I cannot seem to get it working.

Thanks for any advice.

A: 

Try white-space: nowrap

tandu
Already tried that, doesn't work. Thanks
Elliott
Two more: float the main div also, or clear: left on the login div
tandu
No luck on either of them, thanks again.
Elliott
+1  A: 

This is because the content div's width is set to 70% of the browser's window, and will ignore the login div entirely. Try instead to float both the elements. If you set both element's css to float: right;, put the login before your content in the html, and remove the width property from the content's css, then it should view how you want it.

tiltos
Thanks that seems to work, but how can I set the width of the content div as it is only as large as the content inside.
Elliott
a standard method is to put them both in a fixed div. If you look at this site (stackOverflow), you will see whitespace on either side. If you create div called container with a set width (such as 960px), and give it margin: 0 auto;. you would then nest your html as follows:<div id="container"> <div id="content"></div> <div id="login"></div></div>Does that answer your question ok?
tiltos