【问题标题】:Use only one of properties of css class in other css class在其他 css 类中仅使用 css 类的属性之一
【发布时间】:2012-10-29 20:27:34
【问题描述】:

我有一个问题,我需要在其他 css 类中使用 css 类的一个属性。

.class_a {margin:10px;宽度:360px;向左飘浮;颜色:#ffffff; ...等等...}

.class_b { .class_a of margin }

仅在 class_b 中使用 class_a 的边距

谢谢!

【问题讨论】:

  • 在纯 CSS 中不可能。像 LESS 这样的 CSS 预处理器可以做到这一点。
  • 你为什么要这样做?
  • 你能不能把margin的声明移到一个新的类中,然后将该类添加到接收class_a的HTML元素中?
  • 我想使用 jquery ui 主题,但只是颜色和 bg-s。

标签: css


【解决方案1】:

你不能使用传统的 CSS 来做到这一点,你需要使用像 LESSSASS 这样的动态方法

LESS Reference

SASS Reference

【讨论】:

    【解决方案2】:

    您最快的选择可能是使用 firebug 或 chrome 开发工具找到您想要的样式并将它们添加到您的样式表中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-10
      • 1970-01-01
      • 2014-01-24
      • 1970-01-01
      • 2016-07-28
      • 2020-11-20
      • 1970-01-01
      • 2015-05-14
      相关资源
      最近更新 更多