classList 方法中参数的顺序重要吗?

Does the order of parameters in classList methods matter?

我有四个 css 类 根据它们的功能分开,.openModalStyle.closeModalStyle 包含 appearing/disappearing 样式,.openModalTransition.closeModalTransition 包含该样式的过渡 属性。

我想知道标记的顺序对 classList 方法是否重要,因为转换应该附加在样式之前。

let modal = document.querySelector("modal");

// style before transition
modal.classList.add("openModalStyle");
modal.classList.add("openModalTransition");


// transition before style
modal.classList.add("openModalTransition");
modal.classList.add("openModalStyle");

// want to make sure both work properly in all browsers
    .modal{
      width: 200px;
      height: 200px;
      background-color: #f00;
    }
    
    
    /* change opacity */
    .openModalStyle{
      opacity: 1;
    }
    .closeModalStyle{
      opacity: 0;
    }


    /* apply transitions */
    /* they are repeated styles, but i need to keep them seperated for some reason */

    .openModalTransition{
      transition: opacity 2s;
    }
    .closeModalTransition{
      transition: opacity 2s;
    }
<div class="modal"></div>

不,在 classList 中并不重要,因为您只需向元素添加 class,

此外,CSS 的顺序在大多数情况下并不重要,只有在某些情况下才重要,它会在任何时候出现多个 CSS 选择器匹配具有完全相同的元素 specificity.