To solve your issue, I recommend incorporating fadeTo() into your JavaScript code consistently. By using fadeTo(), you can prevent the sudden movement of other elements when transitioning to a new position.
Additionally, I made some optimizations to your JavaScript code. It's worth noting that the <center>
tag is no longer recommended in HTML5, so try to steer clear of using it. Let me know if you have any feedback!
Here's the revised HTML:
<body>
<div id="clickableContainer">
<div class="clickable" id="one"></div>
<div class="clickable" id="two"></div>
<div class="clickable" id="three"></div>
</div>
<article class="slider" style="display:none;" id="1"><div class="back">Back</div></article>
<article class="slider" style="display:none;" id="2"><div class="back">Back</div></article>
<article class="slider" style="display:none;" id="3"><div class="back">Back</div></article>
</body>
JavaScript enhancements:
$(document).ready( function(){
$('#one').on("click",function(){
$("#two, #three").delay(300).fadeTo(300,0, function(){
$('#one').delay(1000).fadeTo(300,0,function(){
$("#one, #two, #three").css("display","none");
$('#1').delay(1900).fadeTo('slow', 1);
});
});
});
// Additional click event handlers for '#two' and '#three'
$('article').on("click",function(){
$(this).fadeTo(300,0,function(){
$(this).css("display","none");
$('#one, #two, #three').delay(800).fadeTo(300,1);
});
});
});
Explore the code snippet at this JSFiddle link.