steveai
steveai

Reputation: 177

how can I center child div inside parent div with margins?

Here is the code

div.content_inner {
    background-color: white;
    -moz-box-shadow: 1px 5px 10px #000;
    -webkit-box-shadow: 1px 5px 10px #000;
    box-shadow: 1px 5px 10px #000;
    margin-left: 10%;
    margin-right: 10%;
}

Website is http://twoandahalfmiles.polymath.io

I'm trying to get the white content are to have margins on each side and I want it to stretch to the top of the website, it doesn't currently do that either.

Thanks in advance!

Upvotes: 0

Views: 80

Answers (1)

Airen
Airen

Reputation: 2169

You can define a fixed width, and set the left and right side margin value of auto.Like this:

.content {
  width: 940px;
  margin-left: auto;
  margin-right: atuo;
}
div.content_inner {
    background-color: white;
    -moz-box-shadow: 1px 5px 10px #000;
    -webkit-box-shadow: 1px 5px 10px #000;
    box-shadow: 1px 5px 10px #000;
   /* margin-left: 10%;
    margin-right: 10%;*/ /*please delete*/
}

Upvotes: 2

Related Questions