Declaring all CSS background properties in one lin

2020-03-01 08:21发布

So here's my code:

background: url(images/my-image.png) no-repeat center center / cover;

This works fine on Chrome and Firefox but not on Safari for some reason?

I used to declare my background-size on it's own line but as I understand it it should be possible to declare all properties in one line using a forward slash?

Any help would be much appreciated. Thanks.

标签: html css safari
1条回答
我只想做你的唯一
2楼-- · 2020-03-01 08:54

As one line short hand code seems do unknown for safari browsers meaning of cover:

background: url(images/my-image.png) no-repeat center center / cover;

I faced the same issue before. And the following worked for all browsers:

background: url(images/my-image.png) no-repeat;
background-position: center;
background-size: cover;/*now this is known for the safari*/
查看更多
登录 后发表回答