We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
有如下代码,请问 HTML 代码中“文本”最终渲染出的颜色分别是?
.red {color: red;} .blue {color: blue;}
<div class="red blue">文本</div> <div class="blue red">文本</div>
Why? CSS 的层叠规则里有一条叫做“后来居上原则”,即两个相同权值的样式,如存在相同的声明属性,则后者获胜。 本题的 CSS 样式里,.blue 和 .red 权值相同,且都声明了 color 属性,但 .blue 在样式表中位于 .red 后面的位置,所以当 HTML 中的同一标签同时引用这两个类名时,以 .blue 的 color 声明为准,和 HTML 中 className 的先后顺序无关。
.blue
.red
color
className
The text was updated successfully, but these errors were encountered:
No branches or pull requests
有如下代码,请问 HTML 代码中“文本”最终渲染出的颜色分别是?
答案
两个都是蓝色Why? CSS 的层叠规则里有一条叫做“后来居上原则”,即两个相同权值的样式,如存在相同的声明属性,则后者获胜。
本题的 CSS 样式里,
.blue
和.red
权值相同,且都声明了 color 属性,但.blue
在样式表中位于.red
后面的位置,所以当 HTML 中的同一标签同时引用这两个类名时,以.blue
的color
声明为准,和 HTML 中className
的先后顺序无关。The text was updated successfully, but these errors were encountered: