Change background image size with media query

admin

Administrator
Staff member
<div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override">
Code:
.logo {
    background-image: url(https://ofbuckleyandbeatles.files.wordpress.com/2011/01/testpattern.gif);
    background-size: 100%;
}

@media(max-width:767px) {
.logo {
    background-image: url(https://ofbuckleyandbeatles.files.wordpress.com/2011/01/testpattern.gif);
  background-size: 50%;
  background-repeat: no-repeat;

}
    }
<pre class="snippet-code-html lang-html prettyprint-override">
Code:
&lt;div class="logo"&gt; &lt;/div&gt;
</div>
</div>


I can't work out why this doesn't work - any ideas why the image doesn't render?

HTML:

Code:
&lt;div class="logo"&gt; &lt;/div&gt;

CSS:

Code:
.logo {
background-image: url(../img/logo_white.png);
background-size: 100%;}

@media(max-width:767px) {
.logo {
background-image: url(../img/logo_white.png);
background-size: 50%;
background-repeat: no-repeat;}
}

Any help greatly appreciated