I have a series of divs that slide down using -webkit-transform from a negative margin-top to a position on the screen. Problem is that they end up where they would normally be sitting if there was no negetive margin-top applied to them.
This means if I show the 2nd div it has an empty space the size of the first div above it. To solve this I can apply a negative margin-top to the 2nd div, but I think thats messy.
My main concern is that if the height of dropdiv1 changes then I would have to reset the values on the click functions to have the other divs line up correctly again when shown.
Is there a way to amend -webkit-transform to incorporate postion:absolute?
My current code is:
CSS:
#dropdiv1 {
-webkit-transform: translate(0, -3000px);
-webkit-transition: all ease-in 1s;
}
#dropdiv2 {
-webkit-transform: translate(0, -3400px);
-webkit-transition: all ease-in 1s;
}
#dropdiv3 {
-webkit-transform: translate(0, -4200px);
-webkit-transition: all ease-in 1s;
}
JQuery:
$('#clickme1').click(
function() {
$('#dropdiv1').css('-webkit-transform','translate(0, -335px)');
});
$('#clickme2').click(
function() {
$('#dropdiv2').css('-webkit-transform','translate(0, -2335px)');
});
$('#clickme3').click(
function() {
$('#dropdiv3').css('-webkit-transform','translate(0, -3300px)');
});
HTML:
<ul class="mainmenu">
<li><a id="clickme1" href="#">Click Me 1</a></li>
<li><a id="clickme2" href="#">Click Me 2</a></li>
<li><a id="clickme3" href="#">Click Me 3</a></li>
</ul>
<div class="showdata" id="dropdiv1">
Lots of random text....
</div>
<div class="showdata" id="dropdiv2">
Lots of random text....
</div>
<div class="showdata" id="dropdiv3">
Lots of random text....
</div>
OK I have found a kind of solution. Still messy but ok:
CSS:
Not particularly a fan but it will do!