dengsa.com
域名年龄: 17年1个月8天HTTP/1.1 304 Not Modified 访问时间:2013年10月01日 00:42:55 接受单位:字节 连接:Keep-Alive Keep-Alive: timeout=5, max=100 动作:User-Agent 网页标记:"196-52029a08-57ff9"
电话那头 2012-01-05 23:16:44 走在路上,想到明日依旧,于是微笑着耸耸肩搭上回家的公车。 一直在想,我应该是不会因为某些事情而抱有患得患失的情绪吧。我不想变得如他们所说的那样,但我也深深地担忧,担忧自己的坚持是否正确。比起两年前,我改变了一些。是的,学会了放下。 生活现在就是我的全部,家庭是最为重要,一切和这温暖相背的苦恼都要抛开。只要生命不息,未来就都还存在,一切都还是希望。并不是没有梦想,努力吧。 感谢吾妻,我爱你。 By 邓撒 | Posted in 思考 | Comments Off [译文]为什么CSS选择器是从右向左执行的? 2011-09-08 23:06:49 原文地址:CSS Selectors parsed right to left. Why? 中文翻译由 dengsa 独立完成,如若转载请注明。 Keep in mind that when a browser is doing selector matching it has one element (the one it’s trying to determine style for) and all your rules and their selectors and it needs to find which rules match the element. This is different from the usual jQuery thing, say, where you only have one selector and you need to find all the elements that match that selector. 记住,当浏览器在做选择器匹配时它会有一个元素(就是试图判定要样式化的那个)还有你所有的规则及选择器,浏览器需要找到哪条规则是和这个元素匹配的。这和 jQuery 之类的不同,嗯,你只有一个选择器然后你需要找出匹配它的所有元素。 If you only had one selector and only one element to compare against that selector, then left-to-right makes more sense in some cases. But that’s decidedly not the browser’s situation. The browser is trying to render Gmail or whatever and has the one it’s trying to style and the 10,000+ rules Gmail puts in its stylesheet (I’m not making that number up). 如果你只有单个选择器并且只有单个元素要和这个选择器比对,“从左至右”有时候是很能讲得通的。但那显然不适用于浏览器环境,浏览器正试图渲染 Gmail 或者其他什么的有一个要样式化的 和 Gmail 放入样式表的那 10,000+ 以上的规则(我并没有夸大这个数字)。 In particular, in the situation the browser is looking at most of the selectors it’s considering don’t match the element in question. So the problem becomes one of deciding that a selector doesn’t match as fast as possible; if that requires a bit of extra work in the cases that do match you still win due to all the work you save in the cases that don’t match. 详细说来,浏览器其实是在考虑大多数选择器并不匹配元素。所以问题就成了要尽快地确定一个选择器是不匹配的;如果那需要稍微更多一点的工作量,不匹配的方案节省的工作量也仍旧好过于匹配的方案。 If you start by just matching the rightmost part of the selector against your element, then chances are it won’t match and you’re done. If it does match, you have to do more work, but only proportional to your tree depth, which is not that big in most cases. 如果你从选择器最右侧部分开始比对你的元素,然后碰巧它不匹配然后就结束了。如果它匹配,你必须做更多的工作,但只和树的深度成比例,很多情况下它不会很大。 On the other hand, if you start by matching the leftmost part of the selector… what do you match it against? You have to start walking the DOM, looking for nodes that might match it. Just discovering that there’s nothing matching that leftmost part might take a while. 另一方面,如果你从选择器最左侧部分开始比对… 你会怎么匹配呢?你必须开始遍历 DOM,查找可能匹配的节点。只是会发现从最左侧部分匹配可能会耗费一点时间然后又一无所获。 So browsers match from the right; it gives an obvious starting point and lets you get rid of most of the candidate selectors very quickly. You can see some data at http://groups.google.com/group/mozilla.dev.tech.layout/browse_thread/thread/b185e455a0b3562a/7db34de545c17665 (though the notation is confusing), but the upshot is that for Gmail in particular two years ago, for 70% of the (rule, element) pairs you could decide that t
© 2010 - 2020 网站综合信息查询 同IP网站查询 相关类似网站查询 网站备案查询网站地图 最新查询 最近更新 优秀网站 热门网站 全部网站 同IP查询 备案查询
2024-07-22 01:43, Process in 0.0101 second.