Front-end-Web-Development-Interview-Question
Front-end-Web-Development-Interview-Question copied to clipboard
有一些我看到的是错误的答案,在这里提出更正
CSS 部分问题与解答中
6. 在HTML文本中,伪类:root总是指向html元素?
这题的答案是正确的,这道题的前提是 “在HTML文本中”,HTML文本中的 root 总是指向 html 元素的。
在W3C中有明确的说明 : 请戳这里查看 CSS3 :root 选择器
14. 如下代码中文本“Sausage”的颜色是?
<ul class="shopping-list" id="awesome">
<li><span>Milk</span></li>
<li class="favorite" id="must-buy"><span class="highlight">Sausage</span></li>
</ul>
#awesome .favorite:not(#awesome) .highlight {
color: red;
}
#awesome .highlight:nth-of-type(1):nth-last-of-type(1) {
color: blue;
}
这里考察的是对CSS选择器优先级的掌握,答案应该是 red。
18. mypic.jpg 会被浏览器加载吗?
<div id="test1">
<span id="test2"></span>
</div>
#test1 {
display: none;
}
#test2 {
background-image: url('mypic.jpg');
visibility: hidden;
}
答案是 会被加载。这里考察的是CSS样式对背景图加载的影响,visibility: hidden 只是不显示,节点在文本流中仍然占有一席之位,背景图仍然会被加载。
关于18的问题,验证过后,确实不会被加载,因为test1的display为none,导致整个元素不被加载,看浏览器的NetWork就会发现这个问题