Jump to content

Strange CSS positioning error


Freedom-n-Democrazy

Recommended Posts

I've got a DIV inside another DIV and I am trying make it centred using margin-left: auto; and margin-right: auto;, but its not working.

This is the hierarchy in which the DIV (DIV.cartcontent) lives in:

 

BODY {

background-attachment: fixed;

background-image: url("/bodybackground.png");

background-position: center;

background-repeat: no-repeat;

color: rgb(255,215,0);

font-family: verdana

}

DIV.main {

background-color: black;

height: 636px;

left: 50%;

margin-left: -635px;

margin-top: -307px;

position: absolute;

top: 50%;

width: 1270px

}

DIV.cartcontent {

border-style: solid;

border-width: 1px;

height: 562px;

margin-left: auto;

margin-right: auto;

margin-top: 57px;

overflow: auto;

overflow-x: hidden;

padding: 5px;

position: absolute

}

 

Does anyone know why its not working?

Link to comment
Share on other sites

change to

 

 

DIV.cartcontent {
   width: 100%;
   border-style: solid;
   border-width: 1px;
   height: 562px;
   margin: 57px auto 0 auto;
   overflow-y: auto;
   overflow-x: hidden;
   padding: 5px;
   position: relative;
}

 

should work for you

 

EDIT: also, why is your main div absolute? perhaps you are misunderstanding the use of position: absolute?

this is meant to take the div out of the "flow" of other elements.. your main div appears to be the div you are using to store all of your info.. position: absolute here is not ideal..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.