I am trying to vertically center my div that is of absolute
position inside a relative
position div. The problem is that my parent div has an ever expanding height
. Today it could be 300, tomorrow 100. So defining the height is not possible but the child div has to be vertically centered.
Here is what I have tried:
.parrent{
position: relative;
}
.child {
background: red;
width: 50px;
height: 50px;
position: absolute;
top: 0;
bottom: 0;
}
<div class="parrent">
<span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span>
<div class="child">
</div>
</div>
As I need this working as soon as possible, I'm open to any solutions.