[英]Different types of class names in html
What is the diff bw什么是差异bw
The difference is that in case:不同之处在于:
class="name"
: to the element will be applied only the properties of class "name" class="name"
:元素将仅应用 class "name" 的属性class="name-new"
: like point one, but in this case the class is "name-new" class="name-new"
:与第一点类似,但在这种情况下,class 是“name-new”class="name new"
: in this case, to element will be applied two different classe: "name" and "new" class="name new"
:在这种情况下,将应用两个不同的类:“name”和“new” The "space" is used to separete multiple classes, same principle is used for the "id". “空格”用于分隔多个类,“id”使用相同的原则。
Also.. the syntax class="name-new"
is not equal to use class="name_new"
.另外.. 语法
class="name-new"
不等于使用class="name_new"
。
1 and 2 - works in the same way. 1 和 2 - 以相同的方式工作。 They are just two different classes.
它们只是两个不同的类别。 The corresponding style will be applied in the HTML element where they are added.
相应的样式将应用于添加它们的 HTML 元素中。
3 - The class 'name' will be applied first, then the class 'new'. 3 - 将首先应用 class 'name',然后应用 class 'new'。 The same/common style properties will be overridden by right side classes.
右侧类将覆盖相同/通用样式属性。
.name {
color:red;
}
.name-new {
color:blue;
}
.new {
font-weight: bold;
color: green;
}
<div class="name"> Name </div> // will appear in red
<div class="name-new"> New-Name </div> // will appear in blue
<div class="name new"> New Name </div> // will appear in bold-green
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.