在我们的应用程序中,当我们在某些页面之间导航时,我们会在进入下一页之前发出服务器请求。发生这种情况时,当前页面上会显示加载图形。奇怪的是,在等待服务器响应完成时,下一页的样式会应用到当前页面。这会导致当前页面的布局发生变化。
有没有办法防止这种情况发生,也许是通过仅在页面实际可见时才对页面应用 css 样式?还是只是为每个页面创建唯一的类以避免冲突?
最佳答案
假设您有 index.html 和 index2.html 作为两个页面, 现在你创建 index.css 并仅在 index.html 中引用它 类似地创建 index2.css 并仅在 index1.html 中引用相同内容
评论后编辑 供引用css priority 最后声明的内部样式表具有高优先级。
关于javascript - jQuery 手机 : the styles for the next page are applied to the current page while making a server connection during page navigation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28483869/