Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在SASS(或纯CSS)中合并两个标记?_Css_Sass - Fatal编程技术网

如何在SASS(或纯CSS)中合并两个标记?

如何在SASS(或纯CSS)中合并两个标记?,css,sass,Css,Sass,我希望对文档中的代码元素使用通常的“灰色背景上的单空间”渲染。HTML文档根据Markdown呈现,可以有三种类型: This is the markdown version with some `inline code`. The block code can be either like this ``` for i in world: say(i) ``` or the SO way like that for i in world: say(i)

我希望对文档中的代码元素使用通常的“灰色背景上的单空间”渲染。HTML文档根据Markdown呈现,可以有三种类型:

This is the markdown version with some `inline code`. The block code can be either like this

```
for i in world:
    say(i)
```

or the SO way like that

    for i in world:
        say(i)

back to normal text
这是呈现给

code{
字体系列:“Ubuntu Mono”,monospace;
背景:浅灰色;
}
前{
背景:浅灰色;
左侧填充:30px;
}
这是带有一些
内联代码的降价版本。块代码可以是这样的

pre, code {
  background: lightgray;
}
还是那样

pre{
  background: lightgray;
  padding-left: 30px;
  code{
      font-family: 'Ubuntu Mono', monospace;
  }
}

返回正常文本

合并CSS中的两个标记:

但我想你已经知道了。解决重复问题。

尝试下面的方法


是的,但是我需要一个额外的
pre
条目,只用于
填充
,然后?我也会使用这种方法,是的。如果你确信
pre
code
始终是
lightgray
的话,这似乎是最干净的一种,这一切都是“你的编码方式”。您可以根据标记或属性进行分组(同时将类的使用放在一边)。我认为对于代码标记,不需要背景,因为它已经分配到元素的父元素中