I'm encountering some issues with keeping my text centered and smoothly resizing when the window size changes.
I have a weather website that showcases only the temperature. I present the temperature in various ways. I utilize local storage to store the temperature for returning visitors and display it until I can process it with my PHP function. Everything seems to function well, except when I resize the page.
I am using jQuery to center the text.
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
return this;
}
and this is the CSS to resize the text based on the viewport of the page.
font-family:BebasNeueRegular;
src:url(BebasNeue-webfont.eot?#iefix) format(embedded-opentype), url(BebasNeue-webfont.ttf) format(truetype), url(BebasNeue-webfont.svg#BebasNeueRegular) format(svg);
font-weight:500;
font-style:normal;
font-size:45vw;
position:relative;
Any advice would be welcomed.
Thank you