首页 > 解决方案 > 如何在 CSS 中添加特定的类

问题描述

如果我向我的 div 添加一个 css 类,它将被 v-slot-tradeMatrixLayout 覆盖。如何在我的 CSS 文件中专门指定这个类,以便只调用它。tradeMatrixLayout 被赋予一个 VerticalLayout。

这将在 chrome 中进行检查

<div class="v-slot v-slot-tradeMatrixLayout">

这是我的 CSS 文件

.tradeMatrixLayout{
 margin-left: 15px !important;
}

div 如何调用我专门编写的课程?

标签: cssfile

解决方案


您还可以使用 javascript 通过操作 DOM 来添加类。

function myFunction() {
    var el = document.getElementsByClassName("v-slot");
    el.classList.add("tradeMatrixLayout");
}

推荐阅读