简体   繁体   English

DOM 中的类定义在 javascript 中连接

[英]class definition in DOM connect in javascript

I don't know what is different between (I) and (II) ?我不知道(I)(II)之间有什么不同? whether these class is same for use in a (js file/css file) or not different ?这些类是否在(js 文件/css 文件)中使用相同或不同?

I: <div class="start-box active">

II: <div class="start-box">

in I you have two class start-box and active but in II you have just one class.在 I 中,您有两个班级开始框活动,但在 II 中,您只有一个班级。 you can use js to add or delete class from element.您可以使用 js 从元素中添加或删除类。 and with css you can set some css property for the active when use event handler you can read this link HTML Event Attributes并且使用 css 您可以在使用事件处理程序时为活动设置一些 css 属性,您可以阅读此链接HTML 事件属性

The class name attribute of an element accepts a single class name, or a space separated list of class names.元素的class名属性接受单个类名或空格分隔的类名列表。

So in所以在

<div class="start-box active">

the div element has two classes, start-box and active , whereas in div元素有两个类, start-boxactive ,而在

<div class="start-box">

the div element is only assigned the one class, start-box . div元素只分配了一个类, start-box

The combination of multiple classes on one element, or even the effect of a single class on an element given its relationship to other elements, is subject to the rules of cascading style sheets (meaning "CSS") .一个元素上的多个类的组合,或者甚至单个类对一个元素的影响(考虑到它与其他元素的关系)都受级联样式表(意思是“CSS”)规则的约束。

I wish you well in learning more about CSS - you may find that the article "Learn to style HTML using CSS"]( https://developer.mozilla.org/en-US/docs/Learn/CSS ) on MDN useful in doing so.我希望你能更好地学习 CSS - 你可能会发现 MDN 上的文章“Learn to style HTML using CSS”]( https://developer.mozilla.org/en-US/docs/Learn/CSS ) 在这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM