【发布时间】:2014-01-16 06:36:20
【问题描述】:
当窗口调整大小时,我的文本保持居中和平滑调整大小时遇到了一些问题。
我有一个显示温度和温度的天气网站。我以几种方式显示温度。如果他们之前访问过并显示它,我会将临时存储在本地存储中,直到我可以用我的 php 函数解析它。所以一切似乎都正常,除非我调整页面大小。
我正在使用 jQuery 使文本居中。
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;
}
这是根据页面视口调整文本大小的 css。
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;
任何提示将不胜感激。
谢谢
【问题讨论】:
-
你到底看到了什么行为?
-
调整大小不顺畅。如果我调整窗口大小,文本将保持相同大小,然后跳变小 25%。
标签: javascript jquery css center viewport