I'm trying to build a small modal plugin but I'm struggling to find a way to hide the modal and be able to fade it in/out using only CSS3 transitions.
Obviously, I can't animate display: none to inherit and using opacity and visibility isn't an option because the content is still technically there, it just can't be seen so it prevents elements beneath it from being used (buttons etc.)
So my thinking was to use jQuery to switch between display: hidden and inherit and then use jQuery to add a class of 'shown' which would trigger the transition. But it's not working. I'm just getting an instant show (as with the blackout element behind). The CSS transitions are working though, I've tested them without the 'display' stuff.
My jQuery so far:
// Modal open trigger
$('.modal-trigger').click(function() {
modal = $('#' + $(this).data('modal-trigger'));
modal.css({'display':'inherit'}).addClass('modal-show');
$('#blackout').css({'display':'inherit'}).addClass('show');
});
Any ideas?