I am facing a situation where I need to make an invisible block expand on hover of its parent block. The parent block has a fixed width, while the expanding child block needs to be full screen width, therefore it is positioned absolutely. However, when the element expands, it covers the content underneath. I tried increasing the height of the parent block with jQuery by adding the parent's height and the height of the expanding child. But because the animation uses max-height, jQuery ends up taking 0 as the child's height.
Below is a sample code snippet and a link to the demo:
<div>
<ul class="list">
<li class="list-el">
<div class="el-top">Expand 1</div>
<div class="el-bottom">Cupcake liquorice cupcake sweet roll ice cream caramels.
Lollipop dragée chupa chups. Sugar plum candy jelly-o bonbon gummies caramels.
Jelly icing tiramisu candy chupa chups chocolate bar.
Sweet pastry jelly-o marshmallow jelly lollipop pie marshmallow cookie.
Lollipop sugar plum lollipop jelly lollipop pudding.
Tart jelly-o gummi bears sweet roll gummi bears.
Jelly icing tiramisu candy chupa chups chocolate bar.
Sweet pastry jelly-o marshmallow jelly lollipop pie marshmallow cookie.
Lollipop sugar plum lollipop jelly lollipop pudding.
Tart jelly-o gummi bears sweet roll gummi bears.
</div>
</li>
<li class="list-el">
<div class="el-top">Expand 2</div>
<div class="el-bottom">Lollipop sugar plum lollipop jelly lollipop pudding.
Tart jelly-o gummi bears sweet roll gummi bears.
Jelly icing tiramisu candy chupa chups chocolate bar.
Sweet pastry jelly-o marshmallow jelly lollipop pie marshmallow cookie.
Lollipop sugar plum lollipop jelly lollipop pudding.
Tart jelly-o gummi bears sweet roll gummi bears.
Jelly icing tiramisu candy chupa chups chocolate bar.
Sweet pastry jelly-o marshmallow jelly lollipop pie marshmallow cookie.
Lollipop sugar plum lollipop jelly lollipop pudding.
</div>
</li>
</ul>
</div>
CSS:
ul{
list-style: none;
max-width: 600px;
margin: 0 auto;
}
.list{
width: 100%;
padding: 0;
}
.list-el{
width: 100%;
height: 75px;
background: #ff00ff;
margin-top: 10px;
}
.el-top{
width: 100%;
text-align: center;
line-height: 75px;
}
.el-bottom{
text-align: center;
-webkit-transition: max-height 1.5s ease;
-moz-transition: max-height 1.5s ease;
transition: max-height 1.5s ease;
position: absolute;
background: #f0fff0;
top: auto;
left: 0;
width: 100%;
text-align: left;
height: auto;
max-height: 0;
overflow: hidden;
}
.list-el:hover .el-bottom{
max-height: 700px;
}
Any ideas or suggestions on how to increase the parent's height (using CSS or JavaScript/jQuery) in the same animated manner?