Ben*_*rke 13 html css safari css3
所以这是我的代码:
background: url(images/my-image.png) no-repeat center center / cover;
Run Code Online (Sandbox Code Playgroud)
这适用于Chrome和Firefox,但出于某种原因却不适用于Safari?
我曾经background-size在它自己的行上声明我,但据我所知,应该可以使用正斜杠在一行中声明所有属性?
任何帮助将非常感激.谢谢.
Bho*_*yar 16
因为一线短手代码似乎对于safari浏览器的含义而言是未知的:
background: url(images/my-image.png) no-repeat center center / cover;
Run Code Online (Sandbox Code Playgroud)
我之前遇到过同样的问题.以下适用于所有浏览器:
background: url(images/my-image.png) no-repeat;
background-position: center;
background-size: cover;/*now this is known for the safari*/
Run Code Online (Sandbox Code Playgroud)
小智 6
背景属性具有以下属性。
url("image path") bg-color例如透明或任何颜色bg-img-repeat例如repeat或no=repeatbg-image-postion垂直和水平例如center centerbg-img-size例如cover, contain, 100%, 800px, 或200px 100px(宽度和高度) 等我们会这样写
background: url("images/my-image.png") transparent no-repeat bottom center / cover;
background-size: cover; /*for safari we can add this sperately*/
Run Code Online (Sandbox Code Playgroud)