Centered Div

CSS

div.outer-div {
height: 170px;
width: 300px;
background-color: lightgray;
}

div.middle-div {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}

HTML

<div class=”outer-div”>
<div class=”middle-div”></div>
</div>
Posted in CSS

Leave a Reply

Your email address will not be published. Required fields are marked *