我使用http://www.patternify.com生成了一些背景图像css代码,并将它们添加到名为backgrounds.less的.less文件中。当我保存文件并通过编译器运行它时,它给我一个解析错误。我似乎无法解决这些错误。
我已将每个背景定义为变量,并使用@import“backgrounds.less”将文件导入到我的主样式。无样式表中;
我得到的确切错误是:
ParseError:/Volumes/Clients/htdocs/gobet2/less/backgrounds.less:1:145中第1行的语法错误 1 @headerbg {background:url(data:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAYAAABWKLW / AAAAIElEQVQIHWP8DwQMQHD6yVcGBhDn1OMvIOo / A4wB4gAACZQd0vY42rMAAAAASUVORK5CYII =)repeat;} [0m
(此操作是由对backgrounds.less的更改触发的)
代码如下。
@headerbg {background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAYAAABWKLW/AAAAIElEQVQIHWP8DwQMQHD6yVcGBhDn1OMvIOo/A4wB4gAACZQd0vY42rMAAAAASUVORK5CYII=) repeat;}
@navbg {background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAYAAABWKLW/AAAAIUlEQVQIHWN8+fL5fwYgeP/uEQMTjCEoJMfABBIBMUAAADLvDH2vTm1NAAAAAElFTkSuQmCC) repeat;}
@subnavbg {background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAYAAABWKLW/AAAAIElEQVQIHWP8DwQMQHD3zgUGBhDnzu3zIOo/A4wB4gAAA+UdgeoweSoAAAAASUVORK5CYII=) repeat;}
@footerbg {background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAYAAABWKLW/AAAAIElEQVQIHWP8DwQMQPDs2TMGBhDn6dOnIOo/A4wB4gAADVod/MNEi1EAAAAASUVORK5CYII=) repeat;}
@basebg {background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFElEQVQIHWN8+/b5fwYgYAIRIAAAOj4DxOCeCacAAAAASUVORK5CYII=) repeat;}
非常感谢任何帮助或解决方案。
感谢。
答案 0 :(得分:0)
变量可以包含值(不是任意规则)。所以你可以定义
@headerbg: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAYAAABWKLW/AAAAIElEQVQIHWP8DwQMQHD6yVcGBhDn1OMvIOo/A4wB4gAACZQd0vY42rMAAAAASUVORK5CYII=) repeat;
(注意变量名后面的:
)后来使用
#header {
background: @headerbg;
}