内联css背景大小的封面

时间:2012-12-27 00:00:47

标签: 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;
}
现在应该工作,我需要用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>

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

我使用内联css错了吗?

2 个答案:

答案 0 :(得分:12)

使用此代码,比@RAS版本更清晰:

background: url(image.jpg) no-repeat center center / cover;

答案 1 :(得分:9)

您需要使用单个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>
相关问题