Ionic4:将图像大小作为背景图像URL的封面

问题描述 投票:1回答:2

我想给离子工具栏提供背景图像,因为图像太大,所以我想使用image-size: cover作为背景图像,以便它最适合离子工具栏。

我试图给出以下格式,但它不起作用,任何想法如何让它工作。

ion-toolbar {
    --background: url(assets/images/background/bg-header-flag.jpg) no-repeat cover;
    --min-height: 200px;
}
angular ionic-framework ionic4
2个回答
0
投票

经过努力,终于得到了答案

    --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


0
投票

您还可以参考以下链接获取背景大小属性:

https://alligator.io/css/background-size-property/

© www.soinside.com 2019 - 2024. All rights reserved.