I'm currently working on implementing a short pop-up feature in my web application that will appear when a user clicks on a code snippet to copy it. However, I'm facing difficulties with preventing the pop-up from causing a shift in the parent div.
The GIF below showcases the issue that occurs after numerous attempts and online searches to address this problem. My objective is to have the copied message bubble smoothly appear at the top right corner of the span containing the room code.
https://i.sstatic.net/d1XPJ.gif
For reference, I have provided a stripped-down version of the interaction in this fiddle. Despite exploring different display and positioning options, I am uncertain about the next steps to take. Thank you in advance for any assistance provided.
https://jsfiddle.net/k6ey1duc/36/
.container {
background-color: #008afa;
width: fit-content;
margin: auto;
padding: 20px
}
.text {
display: inline;
}
.pop-up {
display: none;
background-color: #fe0c0d;
}
#show-hide {
display: block;
margin: auto;
}
<body>
<script>
$(document).ready(function() {
var x = false;
$('#show-hide').on('click', function() {
if (!x) {
$("#pop-up").css({
"backgroundColor": "#fe0c0d",
"display": "inline"
});
x = true;
} else {
$("#pop-up").hide();
x = false;
}
});
});
</script>
<div class='container'>
<p class='text'>
Hello there! <span>Here is a span.</span>
</p>
<div id='pop-up' class='pop-up'>
Here is a pop-up
</div>
<button id='show-hide'>
Click for pop up
</button>
</div>
</body>