When I set autofocus="autofocus" on an input element, then in Firefox, when the page loads, it displays for a split second without the CSS applied. (E.g. content not centered, heading rendered in default font etc.)

当我在输入元素上设置autofocus =“autofocus”时,在Firefox中,当页面加载时,它会在没有应用CSS的情况下显示一瞬间。 (例如,内容不居中,标题以默认字体等呈现)

If I remove the autofocus, the page loads fine and displays when it is ready.

如果我删除自动对焦,页面会正常加载并在准备就绪时显示。

Is there a way to get the page to load normally while using the autofocus feature in Firefox?

在Firefox中使用自动对焦功能时,有没有办法让页面正常加载?

1 个解决方案

#1


14

I have found that by adding some JavaScript in the <head>, the page waits for the style to load before the focus.

我发现通过在中添加一些JavaScript,页面等待在焦点之前加载样式。

I'm not exactly sure why this works, but it does!

我不确定为什么会这样,但确实如此!

Example:

<script type="text/javascript">
    // Fix for Firefox autofocus CSS bug
    // See: http://stackoverflow.com/questions/18943276/html-5-autofocus-messes-up-css-loading/18945951#18945951
</script>

更多相关文章

  1. Web前端-html页面-做过的一个公司的主页
  2. html页面中给img标签的src属性赋值为一张图片的存储路径,图片不显
  3. 加载跨域的HTML页面AJAX
  4. HTML5,简单的注册页面
  5. 在页面重新加载时添加活动链接和jquery幻灯片切换到自定义ajax w
  6. 使用HTML5 canvas做地图(3)图片加载平移放大缩小
  7. 使用img src加载图像会在Mozilla / Chrome中产生不同的大小
  8. 分叉开源PHP代码,项目类加载器策略
  9. PHPCMS V9 的手机门户wap绑定单页面

随机推荐

  1. IPython高级用法及注意事项
  2. React DnD
  3. 编程语言扎堆整容,Python成整容模板
  4. Electron webview完全指南
  5. 开发者必备Mysql命令
  6. 外行人都能看懂的SpringCloud,错过了血亏!
  7. 图说yield
  8. 开发者必备Linux命令
  9. 翻译社重大改版
  10. JVM故障诊断和处理工具