m00t13
m00t13

Reputation: 65

How to make a div centered and all sides be equidistant from wrapper

I have a wrapper that takes up the whole screen and I want to make another div to be centered inside it and all its sides be equidistant from the wrapper.

css:

#wrapper {
    width:100%;
    height:100%;
    top:0;
    left:0;
    position:absolute;
}
#inner_div {
    /*centered, sides equidistant from wrapper*/
}

Upvotes: 2

Views: 138

Answers (1)

Luca Putzu
Luca Putzu

Reputation: 1456

This should do the trick

.a {
  position: absolute;
  top: 50px;
  bottom: 50px;
  left: 50px;
  right: 50px;
  border: 1px solid black;
}

Upvotes: 2

Related Questions