How to Overlap Parent Div From Child Div

Sajjan's the closest from what I can tell, but his has a few flaws:

  1. Position: absolute requires its parent to have a non-static position (this is often done with position: relative, which effectively works the same way as static).
  2. You don't need to set the height and width of the child, just the parent.

Here's my Fiddle for it to demonstrate.

#parent {
    border: 5px solid gray;
    position: relative;
    height: 100px;
    width: 100px;
    margin-left: 50px;
}

#child {
    position: absolute;
    top:0;
    left: 0;
    right: 0;
    bottom: 0;
    background: red;
}

The key here is the position: relative on the parent.

I am curious, though, what exactly you're trying to achieve with this. I have a feeling that whatever it is, there's a better way.

Tags:

Html

Css