在一行中声明所有CSS背景属性-尤其是background-size [英] Declaring all CSS background properties in one line — especially background-size
本文介绍了在一行中声明所有CSS背景属性-尤其是background-size的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
background: url(images/my-image.png) no-repeat center center / cover;
这在Chrome和Firefox上可以正常使用,但由于某些原因在Safari上不能正常使用?
我曾经在自己的行上声明我的background-size
,但是据我所知,应该可以使用正斜杠在一行中声明所有属性吗?
任何帮助将不胜感激.谢谢.
解决方案
对于野生动物园浏览器来说,似乎只有一行简短的短手代码是未知的:
background: url(images/my-image.png) no-repeat center center / cover;
我以前也遇到过同样的问题.以下适用于所有浏览器:
background: url(images/my-image.png) no-repeat;
background-position: center;
background-size: cover;/*now this is known for the safari*/
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.
解决方案
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*/
这篇关于在一行中声明所有CSS背景属性-尤其是background-size的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文