css - 速记 CSS 与普通 CSS 不同

标签 css shorthand

正如我在标题中所说,这个速记:

.settingsSelect {
    background: url('../images/Custom.Select.Background.png'), url('../images/Settings.Input.Background.png') no-repeat, repeat 97%, 0;
    background-size: 12px, contain;
}

显示为

bad shorthand

并使用适当的手写方式:

.settingsSelect {
    background-image: url('../images/Custom.Select.Background.png'), url('../images/Settings.Input.Background.png');
    background-position: 97%, 0;
    background-repeat: no-repeat, repeat;
    background-size: 12px, contain;
}

一切都按预期进行。

longhand

问题出在哪里?谢谢。

最佳答案

速记版本中的语法不正确。应该是:

.settingsSelect {
  background: url('../images/Custom.Select.Background.png') no-repeat 97%, url('../images/Settings.Input.Background.png') repeat 0;
}

可以这样想:

.selector {
  background: background1, background2, background3, etc;
}

其中 background1background2 等都是 background 的简写:

url() repeat X%;

关于css - 速记 CSS 与普通 CSS 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46456921/

相关文章:

css - 居中对齐元素然后隐藏一些但仍然保持居中对齐

css - 是{背景:0;} valid CSS?

ruby - 将项目添加到 Ruby 中的数组,即使变量不存在

使用 return 时的 PHP 速记 If/Else

html - 高度 100% 和溢出

html - 只对图像的一部分进行灰度化?

html - 使用 HTML 表单提交对象的 JSON 数组

properties - C++/CLI 速记属性

JavaScript 简写 if 语句,没有 else 部分

javascript - 使用 javascript 根据滚轮设置 div 元素的位置