css - 仅在表格内设置类样式

标签 css class styles content-management-system predefined-variables

我正在使用带有预定义类 (cbFormFieldCell) 的 CMS。 所以我无法更改某些类元素,因为它们在网站的其他部分使用。如果我更改该类的每个元素的格式,网站就会崩溃。

我只想在 <table class="tabelle"> 中更改类“cbFormFieldCell”的样式.表格之外的其他元素可能不会更改。

.cbFormFieldCell { min-width: 300px; max-width: 300px; overflow: hidden;} 

这适用于网站的每个类别。但是有些东西坏了。

是否可以这样做:

仅更改表 class="tabelle"中的预定义 class="cbFormFieldCell"元素?

例如

.tabelle.cbFormFieldCell 
{ min-width: 300px; max-width: 300px; overflow: hidden; }

有人能帮忙吗?

最佳答案

CSS 类之间的“空格”用于定位不同的元素。您将在下面找到一个示例,当您组合不带或带空格的类时会发生什么。

希望这能帮助您了解如何定位您的元素。

.parent-1 .child {
  color: green;
}

.parent-2.child {
  color: red;
}


/* addition styling */

p {
  padding: 20px;
  background-color: #eff0f1;
  border-radius: 10px;
}
<!-- Without container -->
<p class="child">No CSS rules are applied here.</p>

<!-- With containers -->
<div class="parent-1">
  <p class="child">This will be targeted: green</p>
</div>

<div class="parent-2">
  <p class="child">No CSS rules are applied here.</p>
</div>


<div class="parent-2 child">
  <p class="child">This will be targeted: red</p>
</div>

关于css - 仅在表格内设置类样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56989498/

相关文章:

javascript - 无法在鼠标悬停时显示工具提示,jquery1.11

javascript - 具有不透明度和 z-index 的 slider 无法正常工作

java - 基本 Java 对象类将对象返回为 null?

c++ - 为什么我不能打印二叉树?

css - 需要 Bootstrap 的大集合,但需要更大的灵活性

css - React - 如何将类和内联样式作为 props 传递

Ruby 的 one liner "and return"

html - 我怎样才能水平对齐链接

html - 强制 [innerHTML] 内容适应 div 宽度

javascript - 使用 es6 类进行自调用类实例化