Declaring all CSS background properties in one lin

2020-03-01 08:56发布

问题:

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.

回答1:

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


标签: html css safari