简体   繁体   English

如何防止网站布局在加载时发生偏移?

[英]How do I prevent my website layout from shifting while loading?

Problem: 问题:

When I load a website that I designed, the layout is wonky for a brief moment while the page loads, then snaps into the correct place. 当我加载我设计的网站时,页面加载时,布局会短暂出现,然后卡入正确的位置。 This behavior occurs in at least Safari and Chrome. 至少在Safari和Chrome中会发生此行为。

How to I keep everything in the proper, final place while the page loads? 页面加载时如何将所有内容保存在正确的最终位置?

Code: 码:

HTML in question on codepad (with details changed for privacy reasons): http://codepad.org/GSGHYF0N 键盘上有问题的HTML(出于隐私原因更改了详细信息): http : //codepad.org/GSGHYF0N

Stylesheet: http://codepad.org/Yr4ULwi0 样式表: http//codepad.org/Yr4ULwi0

Additional Info: 附加信息:

  • The most obvious thing that is out of place is the <h2>Location</h2> . 最明显的地方是<h2>Location</h2>
  • Images are all the size indicated in the HTML and CSS. 图片的大小均在HTML和CSS中指定。
  • This is not the problem where the entire layout shifts as one because a scroll-bar appears. 由于滚动条出现,因此整个布局不会移动为一个,这不是问题。

Resources 资源资源

Information on Google Developers have been useful, but haven't indicated how to fix my particular problem. 有关Google Developers的信息非常有用,但是并未指出如何解决我的特定问题。 However, StackOverflow won't let me post these links because of spam-prevention. 但是,由于防止了垃圾邮件,StackOverflow不允许我发布这些链接。

http://jsfiddle.net/QHeG8/ http://jsfiddle.net/QHeG8/

I can't replicate the issue but it could be caused by the webfonts loading and rendering. 我无法复制该问题,但这可能是由webfonts加载和渲染引起的。

That would explain why <h2>Location</h2> moves - because it's position relies on the width of the <h3>Tagline</h3> 那可以解释为什么<h2>Location</h2>移动-因为它的位置取决于<h3>Tagline</h3>的宽度

You could try using standard system fonts to see if that resolves it. 您可以尝试使用标准系统字体来查看是否可以解决该问题。

Also if you have Dev Tools open that'll slow down page rendering and also disable your cache (if you have that option ticked) 另外,如果您打开了开发工具,这将减慢页面渲染速度并禁用缓存(如果选中了该选项)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 加载时如何防止图像移位? - How to prevent images from shifting content when loading? 如何使我的网站放大和缩小而不影响中心的网站布局? - How do I make it so my website zooms in and out without effecting the layout of the website from the center? 当我点击某个页面时,如何防止导航栏内容向左移动? (网站链接如下) - How can I prevent the navbar content from shifting to the left when I click on a certain page? (website linked below) 隐藏表格中的其他单元格时如何防止表格单元格移动? - How do I prevent table cells from shifting when hiding other cells in table? 如何阻止移动设备在我的网站上自动下载PDF? - How do I prevent mobile devices from automatically downloading a PDF on my website? Facebook iframe 没有加载到我的网站上。 我如何解决它? - Facebook iframe not loading on my website. How do I fix it? 如何防止其他文本在 hover 和 CSS 上移动? - How can I prevent other text from shifting on hover with CSS? 如何防止网站左右拉伸? - How do I prevent the website from stretching to left and right? 在避免GUID的同时如何防止HTML被利用? - How do I prevent my HTML from being exploitable while avoiding GUIDs? 放大和缩小时如何防止图像移位? - How do I keep my images from shifting when zooming in and out?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM