需求:给收藏数字前面通过::before伪元素添加图标

相关代码:

.goods-info .collect {
position: relative;
}
.goods-info .collect::before {
content: '';
position: absolute;
left: -15px;
top: -1px;
width: 14px;
height: 14px;
background: url("~assets/img/common/collect.svg") /14px 14px;
}

代码中出现了  background: url("~assets/img/common/collect.svg") 0 0/14px 14px令人费解,于是通过百度以及在控制台更改数字观察变化,理解如下:

  • 背景缩写属性可以在一个声明中设置所有的背景属性。可以设置的属性分别是:background-color, background-position, background-size, background-repeat, background-origin, background-clip, background-attachment,和background-image。如果上述值缺少一个,这不要紧,也是可以的。
  • 语法:background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit;
  • background: url("~assets/img/common/collect.svg") 0 0/14px 14px 说明:
    第一个数字0表示背景颜色:

    改为pink后:

   第二个0/14px的含义:

     0 是background-position的属性简写。background-position 属性设置背景图像的起始位置。https://zhidao.baidu.com/question/141723600.html

     14px 是background-size的属性简写。background-size 属性规定背景图像的尺寸。https://www.w3school.com.cn/cssref/pr_background-size.asp

   最后14px和前面14px共同构成background-size:(这个14px可省略)

以上就是对该句代码的理解。

最新文章

  1. HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application 错误
  2. Python-第三方库requests详解
  3. apache 虚拟ip
  4. mac平台scala开发环境搭建
  5. .net操作xml文件(新增.修改,删除,读取)---datagridview与xml文件
  6. XCODE快捷键个人总结
  7. 浙大PTA - - File Transfer
  8. QQ互联OAuth2.0 .NET SDK 发布以及网站QQ登陆示例代码
  9. heritrix 3.2.0 -- 环境搭建
  10. js的this几种用法
  11. Delphi组件开发-在窗体标题栏添加按钮(使用MakeObjectInstance(NewWndProc),并处理好多消息)
  12. 随机数、continue、break
  13. [译]JDK 6 and JDK 7中的subString()方法
  14. C#实现多级子目录Zip压缩解压实例
  15. Django 系列博客(十二)
  16. 故障公告:docker swarm集群“群龙无首”造成部分站点无法访问
  17. LoadRunner【第一篇】下载、安装、破解
  18. Ubuntu系统建立交叉编译环境
  19. python入门(十三):面向对象(继承、重写、公有、私有)
  20. odoo 11 之signup_with_phone模块分析

热门文章

  1. GoJS事件
  2. tp5--Excel表格导入导出
  3. 十六, Oracle约束
  4. Openstack object list 一次最多有一万个 object
  5. cocos2dx新建项目
  6. 虚拟化KVM之概述(一)
  7. build.gradle 详解(一)
  8. js之 DOM与BOM
  9. SpringMVC Root WebApplicationContext启动流程
  10. 你所不知道的Python | 字符串连接的秘密