Hey there, experts!
I have a question regarding my HTML code:
<div class="full-height">
<h1>Lorem</h1>
</div>
Currently, I am using jQuery to set the height of div.full-height
dynamically like this:
$(document).ready(function() {
function setHeight() {
viewportHeight = $(window).height();
$('.full-height').height(viewportHeight);
};
setHeight();
$(window).resize(function() {
setHeight();
});
});
Now, I want to center the position of the h1
within div.full-height
using jQuery UI like so:
$('.full-height > h1').position({
my: 'center center',
at: 'center center',
of: '.full-height'
});
The issue I'm facing is that it only works correctly when I set a fixed height
property in CSS.
When div.full-height
has a full height but the h2
inside it remains stuck at the top because jQuery UI's .position()
method doesn't recognize that div.full-height
has 100% height.
Any suggestions on how I can resolve this?
Thanks,
Ralph