对background: url("~assets/img/common/collect.svg") 0 0/14px 14px 的理解
2024-10-09 01:41:37
需求:给收藏数字前面通过::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可省略)
以上就是对该句代码的理解。
最新文章
- 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 错误
- Python-第三方库requests详解
- apache 虚拟ip
- mac平台scala开发环境搭建
- .net操作xml文件(新增.修改,删除,读取)---datagridview与xml文件
- XCODE快捷键个人总结
- 浙大PTA - - File Transfer
- QQ互联OAuth2.0 .NET SDK 发布以及网站QQ登陆示例代码
- heritrix 3.2.0 -- 环境搭建
- js的this几种用法
- Delphi组件开发-在窗体标题栏添加按钮(使用MakeObjectInstance(NewWndProc),并处理好多消息)
- 随机数、continue、break
- [译]JDK 6 and JDK 7中的subString()方法
- C#实现多级子目录Zip压缩解压实例
- Django 系列博客(十二)
- 故障公告:docker swarm集群“群龙无首”造成部分站点无法访问
- LoadRunner【第一篇】下载、安装、破解
- Ubuntu系统建立交叉编译环境
- python入门(十三):面向对象(继承、重写、公有、私有)
- odoo 11 之signup_with_phone模块分析