如何浏览器阅读和跨preT CSS? [英] How do browsers read and interpret CSS?

查看:215
本文介绍了如何浏览器阅读和跨preT CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题的两个部分:


  1. 请浏览器有一个内置的CSS跨preTER就像他们对JavaScript做什么?

  2. 在当前究竟浏览器读取CSS,当它应用CSS?

具体来说,我想澄清为什么JavaScript和CSS在使用JavaScript是不同的,你需要多少或专门等到在window.onload所以跨preTER能够正确的getElementById。然而,在CSS你可以选择和应用样式类和ID的所有老谋深算nily。

Specifically, I would like clarification on how or why JavaScript and CSS are different in that with JavaScript you need to specifically wait until window.onload so the interpreter can correctly getElementById. However, in CSS you can select and apply styles to classes and ids all wily nily.

(如果它甚至事项,假设我指的是一个基本的HTML页面的头部外部样式表)

(If it even matters, assume I am referring to a basic HTML page with an external stylesheet in the head)

推荐答案

如果你有一个缓慢的连接,随时随地最近的工作,你会发现,CSS将应用于元素内容作为DOM结构载荷。由于CSS是不是一种编程语言,它不依赖于对象在给定时间是可被正确解析(JavaScript的),并且浏览器是能够作为其检索由多个HTML来简单地重新评估该页面的结构将样式应用于新的元素。

If you've worked with a slow connection anytime recently, you'll find that CSS will be applied to elements as they (slowly) appear, actually reflowing page content as the DOM structure loads. Since CSS is not a programming language, it doesn't rely on objects being available at a given time to be parsed properly (JavaScript), and the browser is able to simply re-assess the structure of the page as it retrieves more HTML by applying styles to new elements.

也许这就是即使在今天,为什么,移动Safari的瓶颈不是在任何时候都在3G连接,但它是网页渲染。

Perhaps this is why, even today, the bottleneck of Mobile Safari isn't the 3G connection at all times, but it is the page rendering.

这篇关于如何浏览器阅读和跨preT CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆