Invalid Property Value on background-image

后端 未结 5 1004
北荒
北荒 2020-12-06 09:35
.up { background-image: url(\'/design-library/profound_test/images/cab_images/white-arrow-up.png\') 50% 50% no-repeat; }

This code is giving me an

相关标签:
5条回答
  • 2020-12-06 10:00

    Even if you do everything described above, you may get an "invalid property value" in Firefox. The workaround is to convert:

    background: url(../img/showcase.jpg) no-repeat top center fixed/cover;
    

    into:

    background: url(../img/showcase.jpg) no-repeat top center;
    background-attachment: fixed;
    background-size: cover cover;
    
    0 讨论(0)
  • 2020-12-06 10:05

    Just delete ../ and use it as

    background: url(img/showcase.jpg) no-repeat top center;
    
    0 讨论(0)
  • 2020-12-06 10:07

    This error also occurs in Chrome when you don't use apostrophes and your file has spaces. Simply change:

    background-image: url(../img/file with spaces.png);
    

    to:

    background-image: url('../img/file with spaces.png');
    
    0 讨论(0)
  • 2020-12-06 10:16

    Yep because the background-image property is for the image part only, not the position or repeat properties of the background, use background:

    .up { 
        background: url('/design-library/profound_test/images/cab_images/white-arrow-up.png') 50% 50% no-repeat; 
    }
    
    0 讨论(0)
  • 2020-12-06 10:26

    Chrome* will also throw this warning (and doesn't display the bg image), if you have a blank space between url and ( like:

    background-image: url ('img/web-bg.png');
                         ^
    

    (Which was the reason for me to search and find this question but no answer and then doing trial and error.)

    • ... maybe depending on the Chrome version, I assume.
    0 讨论(0)
提交回复
热议问题