项目中想要使用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%
}

 

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2021-05-25
  • 2021-12-18
  • 2021-07-26
  • 2021-05-31
  • 2021-12-29
  • 2022-12-23
猜你喜欢
  • 2021-06-21
  • 2022-12-23
  • 2021-10-08
  • 2021-08-04
  • 2021-04-27
  • 2022-12-23
相关资源
相似解决方案