内联css背景大小的封面

Ivo*_*Ivo 4 css

我有以下css代码

.imgf{
    background: url(/thatscooking/FotoTC/FotoTC/ALWIN01.JPG) no-repeat center center ; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
Run Code Online (Sandbox Code Playgroud)

这应该工作,因为它现在我需要用PHP更改img所以我正在尝试使用内联css

 <div style="background: url(/thatscooking/FotoTC/FotoTC/ALWIN01.JPG) no-repeat center center" 
    style="background-size: cover"
    style="-webkit-background-size: cover" 
    style="-moz-background-size: cover" 
    style="-o-background-size: cover" 
    class="imgf ">
<div id="naamb"><p>Album Naam</p></div></div>
Run Code Online (Sandbox Code Playgroud)

只是现在是背景大小的封面不起作用而且没有出现在萤火虫中

我使用内联css错了吗?

Fre*_*d K 18

使用此代码,比@RAS版本更干净:

background: url(image.jpg) no-repeat center center / cover;
Run Code Online (Sandbox Code Playgroud)


RAS*_*RAS 10

您需要使用单个style标签.

<div style="background: url(/thatscooking/FotoTC/FotoTC/ALWIN01.JPG) no-repeat center center;
            background-size: cover;
            -webkit-background-size: cover;
            -moz-background-size: cover; 
            -o-background-size: cover;" 
    class="imgf ">
<div id="naamb"><p>Album Naam</p></div></div>
Run Code Online (Sandbox Code Playgroud)