下面的 css 正在使用 contains ,因为它单独作为背景大小给出,但不是使用背景中给出的简写
即使我也渴望知道CSS中背景属性的参数顺序
body {
background: #00ff00 url("smiley.gif") no-repeat fixed center;
background-size:contain,contain;
}
body {
background: #00ff00 url("smiley.gif") no-repeat contain,contain fixed center;
}
but this is not working as i tried this shorthand method as above Run Code Online (Sandbox Code Playgroud)
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>Run Code Online (Sandbox Code Playgroud)
单独使用没有问题,但需要知道是否有任何方法可以在简写背景属性中使用background-size:contain
即使你可以通过在 W3School 的示例中进行更改来查看它,这里是它的 url
background: #00ff00 url("smiley.gif") no-repeat fixed center / contain;
Run Code Online (Sandbox Code Playgroud)
这应该有效。