My website has a page layout and style similar to the example provided in this JsFiddle.
When I use JQuery to click on a button, the content is displayed correctly as shown below:
https://i.sstatic.net/V89qa.jpg
However, if I scroll down the page first and then click the button, the content does not display properly as seen here:
https://i.sstatic.net/jJvHN.jpg
Could you please provide guidance on how to handle this situation?
I have implemented the following jQuery code for this purpose. However, it appears that either the offset
or position
properties are not functioning properly:
$('#btn').click(function(){
var t = $(this).offset();
console.log(t);
$('.control-container').css('top', t.top + 20 + 'px');
$('.control-container').css('display', 'block');
});
$(document).on('scroll', function(){
$('.control-container').css('display', 'none');
});