angular - Ionic4:将图像大小作为背景图像 url 的封面
问题描述
由于图像太大,我想将背景图像提供给 ion-toolbar,因此我想将其image-size: cover
用于背景图像,以使其最适合 ion-toolbar。
我试图以下面的格式给出,但它没有用,不知道如何让它工作。
ion-toolbar {
--background: url(assets/images/background/bg-header-flag.jpg) no-repeat cover;
--min-height: 200px;
}
解决方案
挣扎了这么久终于得到了答案
--background: url('assets/images/background/bg-header-flag.jpg') center/ cover no-repeat;
下面是使用背景属性简写的语法。
background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit;
有关更多详细信息,请查看https://www.w3schools.com/cssref/css3_pr_background.asp
推荐阅读
- c# - WinForms透明图片绘制绘制旧背景
- vue.js - Vue 没有检测到组件
- spring - Spring security AuthenticationServiceException 转换为 InsufficientAuthenticationException
- amazon-web-services - AWS SQS 阻止出列以防背压
- python - 在 pyqt 中,按钮单击连接在新窗口中不起作用
- python - 使用服务主体连接 Azure SQL Server
- javascript - 同一页面上有多个不可见的 google recaptcha
- javascript - JS DOM | 选择 DOM 元素的所有子元素
- python - 在 Elementtree 中找不到元素
- python - distutils.util.split_quoted 和 shlex.split 有什么区别