css - 使用 Less CSS 时解析错误返回具有背景属性的无法识别的输入错误消息?

标签 css less

我无法使用 LESS CSS 库找出我的 css 有什么问题。

当我使用 LESS 运行我的网站时出现此错误。但对我来说,CSS 似乎是有效的。我的 CSS 有什么问题,或者我不能使用 LESS?

background: url(css/img/home-bg3.jpg) no-repeat;
    background-clip: ( transparent, transparent ), url(css/img/home-bg3.jpg) no-repeat;
    background: -webkit-linear-gradient( transparent, transparent ), url(css/img/home-bg3.jpg) no-repeat;
    background: -moz-linear-gradient( transparent, transparent ), url(css/img/home-bg3.jpg) no-repeat;
    background: -o-linear-gradient( transparent, transparent ) , url(css/img/home-bg3.jpg) no-repeat;
    background-size: 100% cover;

最佳答案

background-clip 属性的值似乎无效,这导致 less 编译器抛出错误。

background-clip 仅支持border-box or content-box or padding-box or 继承作为值。

例如,下面的代码可以正常编译。

.sample{
    background: url(css/img/home-bg3.jpg) no-repeat;
    background-clip: content-box;
    background: -webkit-linear-gradient( transparent, transparent ), url(css/img/home-bg3.jpg) no-repeat;
    background: -moz-linear-gradient( transparent, transparent ), url(css/img/home-bg3.jpg) no-repeat;
    background: -o-linear-gradient( transparent, transparent ) , url(css/img/home-bg3.jpg) no-repeat;
    background-size: 100% cover;
}

background-clip - MDN Specification

补充说明:

错误实际上是由于以下区域中指示的缺失值而引发的:

background-clip: ( transparent, transparent ), url(css/img/home-bg3.jpg) no-repeat;
/*--------------^*/

下面的代码可以正常编译,但不会有任何效果,因为根据规范,background-clip 属性不支持该值。

background-clip: linear-gradient( transparent, transparent ), url(css/img/home-bg3.jpg) no-repeat;

关于css - 使用 Less CSS 时解析错误返回具有背景属性的无法识别的输入错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20296268/

相关文章:

css - 输入[类型 ="image"] 不会让步

php - 站点范围内的 jQuery 音频播放器的可访问性问题

php - 使所有 CSS 内联 - Class Issue

html - css 不适用于 bootstrap less

css - less.js 负载影响

css - 可以通过 lesscss 中的另一个变量设置参数默认值吗?

javascript - 使用 Materialise 的嵌入式日历

javascript - 选项卡内容不会在选项卡单击时显示

jquery - 将新的 js 文件包含到 Magento 2.2 中?

css - 保存以下划线开头的 LESS 文件不会在 Web Essentials 2013 中生成 css