...

View Full Version : Internet Explorer - Content won't stay inside a div?



katz640
11-07-2011, 11:38 PM
Hello! I'm working on editing a profile on a website that I'm a member of and I'm having trouble making things look properly on IE.

You should be able to see my profile without having to make an account:

http://www.neopets.com/userlookup.phtml?user=katz640

When I check it on FF, Chrome, Opera, and Safari, everything seems to look the way it should. However, when I look at it in IE, I notice that all the info doesn't go inside the #content div. It all just spills out into the #main div instead.

I tried posting the whole site code, but it's too long! Sorry about that.

Here's the portion with my CSS:




<style type="text/css">
#header, #ban, #footer, hr, #ncmall, .contentModuleHeader, .contentModuleHeaderAlt {
display: none;
}
.contentModule {
border: none;
}
.contentModuleContent {
background: none;
}
.contentModuleTable {
border: none;
}
body {
background-color: #000000;
}
#main {
position: absolute;
top: 100px;
left: 0px;
padding-top: 20px;
padding-left: 10px;
width: 1000px;
height: 1000px;
border: 1px solid #FF0000;
background-color: transparent;
}
#content {
width: 650px;
height: 350px;
background-color: #FFFFFF;
overflow: hidden;
}
#a {
width: 620px;
height: 300px;
margin-left: -20px;
margin-top: 0px;
border: 1px solid #FF0000;
overflow: auto;
}
#userinfo {
position: relative;
top: 1000px;
}
#usercollections {
position: relative;
top: 1000px;
}
#userneopets {
position: relative;
top: 2000px;
width: 550px;
}
#usertrophies {
position: relative;
top: 3000px;
width: 650px;
height: 350px !important;
border: 1px solid #FF0000;
overflow: auto;
}
#usershop {
position: absolute;
top: 400px;
left: 10px;
height: 225px !important;
background-color: #FFF;
}
#usershop table {
width: 200px !important;
height: 200px !important;
}
#userneohome {
position: absolute;
top: 400px;
left: 235px;
width: 200px;
height: 200px;
background-color: #FFF;
}
#userneohome td {
width: 200px !important;
height: 200px !important;
}
#habitarium {
position: absolute;
top: 400px;
left: 460px;
height: 200px !important;
background-color: #FFF;
}
#habitarium table {
width: 200px !important;
height: 200px !important;
}
#l {
position: absolute;
top: 100px;
left: 675px;
}
#l a {
color: #FFF;
background: #CCC;
padding: 10px;
margin: 5px;
display: block;
}
#l a:hover {
background: #FD1;
}
</style>

<div id="a">
Under major construction.
</div>
<div id="l">
<a href="#a">About Me</a>
<a href="#userinfo">User Info</a>
<a href="#userneopets">Neopets</a>
<a href="#usertrophies">Trophies</a>
<a href="/~Wizarmon">Portfolio</a>
</div>



Is there anything I could do to fix it? Thank you very much for your time.

Excavator
11-08-2011, 12:31 AM
Hello katz640,
You should not be using tables for anything you have here yet... tables are for tabular data. See the link about tables in my signature line below.

Other than that, you put 1297px of stuff in #content but set the height on that element at 350px.
You may not realize you style #content twice in your CSS, once from default.css and once again from embedded styles.

Have a quick study of the box model.
See the box model here (http://www.w3.org/TR/CSS2/box.html). The box model says that whatever you put inside an element cannot be larger than that element. margin/padding/border all count when figuring width/height.

Instead of giving #content a height, try making your CSS look like this -



/* Your mom... I mean, page content
#content {
width: 996px;
vertical-align: top;
clear: left;
}
*/

#content {
width: 650px;
/*height: 350px;*/
background-color: #FFFFFF;
overflow: auto;
}



Of course, now there are other issues with the content of #content breaking the rules of the box model.

The box model seems to be the hardest concept for new coders to grasp. You should study that a bit.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum