1.首先创建mixin.styl文件代码如下:

bg-image($url)  // 创建bg-image($url)函数
background-image: url($url + "@2x.png")
@media(-webkit-min-device-pixel-ratio: 3),(min-device-pixel-ratio: 3)
background-image: url($url + "@3x.png") 2.编写html代码 <div class="title">
<span class="brand"></span>
<span class="name"></span>
</div> <style lang="stylus" rel="stylesheet/stylus">
@import "../../common/stylus/mixin.styl" //引用mixin.styl文件 .brand display: inline-block
width: 30px
height: 18px
bg-image('brand') // 使用bg-image($url)函数 $url为变量:brand
background-size: 30px 18px
background-repeat: no-repeat </style> 注释 bg-image('brand')中 brand为/header/brang.@2x.png || brang.@3x.png的图片名 /header/brang.@2x.png || brang.@3x.png为文件路径 此处使用stylus语法

转自https://blog.csdn.net/qq_38229202/article/details/69676697

最新文章

  1. Android APK是否需要预解压
  2. 洛谷 P1038 神经网络 Label:拓扑排序 &amp;&amp; 坑 60分待查
  3. SQL Server中的事务日志管理(2/9):事务日志架构概述
  4. ubuntu E: Could not get lock /var/lib/dpkg/lock - open
  5. uploadify插件实现多个图片上传并预览
  6. 移动端 touchmove高频事件与requestAnimationFrame的结合优化
  7. 社群系统 ThinkSNS+ 中如何利用 Laravel 表单验证来验证用户名的?(我朝独有需求,两个字母占一个汉字。。。)
  8. HTML学习笔记7:图片与超链接
  9. AppBoxFuture(五): 分布式文件存储-Store Everything
  10. openstack搭建之-horizon配置(14)
  11. c# chart控件柱状图,改变柱子宽度
  12. 安装zabbix时PHP ldap Warning
  13. 2018面向对象程序设计(Java)第17周学习指导及要求
  14. 有登陆认证的情况下如何使用Wisdom RESTClient?
  15. Spring Framework启动详解
  16. phpstorm使用zen coding 快速编辑补全html/css代码
  17. Spring3 访问静态资源
  18. 【spring mvc】application context的生命周期
  19. 阻止form提交数据,通过ajax等上传数据
  20. 运用模型绑定和web窗体显示和检索数据(Retrieving and displaying data with model binding and web forms)

热门文章

  1. 18春季训练01-3/11 2015 ACM Amman Collegiate Programming Contest
  2. ffmpeg 版本升级到 4.0 增加 libaom 库 [AOMedia 的 AV1 视频编码格式]
  3. InnoDB 与 MYISAM的区别和联系
  4. JS访问SpringMVC后台
  5. Python split()
  6. PHP中$_POST和$_GET的用法
  7. 牛客网 python 求解立方根
  8. (一)STL体系结构基础介绍
  9. 第十八单元 nginx服务
  10. MongoDB的简单操作