less 路径 写法

项目中想要使用less【css中希望能跟使用变量来控制图片路径】

html:

<header></header>

less:

@url: "http://img0.bdstatic.com/img/image/shouye/";

header{
    height: 4em;
    background: url('@{url}jianbihua0626.jpg') no-repeat;  /* 注意:url里面的''是必要的,否则解析为css的时候好像就会出错 */
    background-size: 100%;
}

解析后的css :

header {
    height: 4em;
    background: url('http://img0.bdstatic.com/img/image/shouye/jianbihua0626.jpg') no-repeat;
    background-size: 100%
}
高否?富否?帅否? 否? 滚去学习!
原文地址:https://www.cnblogs.com/baixc/p/4604055.html