Center absolute div

by infous

HTML

<div class="h">
<div class="a sheet">
    <div class="b">
        
    </div>
</div>
</div>

CSS

body {
    position: relative;
}

.h {
    background: #eee;
    height: 200px;
    position: relative;
    width: 100%;
}

.a {
    background: transparent;
    height: 100%;
    left: 50%;
    position: absolute;
    top: 0;
}

.b {
    background: green;
    height: 100%;
    left: -50%;
    position: absolute;
    width: 100%;
}

.sheet {
   width: 400px;
}