内容简介:Let's say we have the following set of rules in a CSS file:And the following tags in our HTML:The question is:
Let's say we have the following set of rules in a CSS file:
.red {
color: red;
}
.blue {
color: blue;
}
.green {
color: green;
}
And the following tags in our HTML:
<div> First div.</div> <div> Second div.</div> <div> Third div.</div>
The question is: what color will we have for these divs? Stop for a few seconds and try to answer the question.
The correct answer: they’re all green.
The order of the class names in HTML tags has no importance on the styles. The lines class="red green blue"
, class="blue red green"
or class="green blue red"
are the same thing.
All 3 selectors have the same specificity (just a simple class selector). And given that .green
comes later in the stylesheet, it will override the .red
and .blue
selectors.
Therefore all the divs will have the color green.Cascading wins again.
By the way, this can make a great CSS interview question
I hope you have enjoyed this article and if you would like to get more articles about React and frontend development you can always sign up for my email list.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
计算机图形学与几何造型导论
戈德曼 / 邓建松 / 2011-9 / 69.00元
《世界著名计算机教材精选:计算机图形学与几何造型导论》是世界著名计算机教材精选之一。《世界著名计算机教材精选:计算机图形学与几何造型导论》共四部分三十章节,内容包括乌龟绘图,应用递归乌龟程序生成分形,分形的奇特性质,仿射变换,仿射几何:二维计算机图形学的连点过程,应用迭代函数系统生成分形,不动点定理及其推论,递归乌龟程序与共形迭代函数系统等。《世界著名计算机教材精选:计算机图形学与几何造型导论》可......一起来看看 《计算机图形学与几何造型导论》 这本书的介绍吧!