-1

I have the following code:

.imgleft{
    background-image: url("logo.png");
    background-size: 100%;
    float: left;
}

... but I want to make my website responsive, so when my width is smaller than 650 I want my image gone.

I tried following code, but it doesn't work :

@media screen and (max-width: 650px) {
    .imgleft{
        background-color: none;
    }
}
John Slegers
  • 45,213
  • 22
  • 199
  • 169

2 Answers2

1

You are just removing the background-color of image, which won't hide it :)

Try with display:none

@media screen and (max-width: 650px) {
    .imgleft{
        display: none;
    }
}
Sachin
  • 40,216
  • 7
  • 90
  • 102
0

You're setting the value of your background-color to none, while you are supposed to set the value of your background-image to none.

So, what you're trying to achieve, is this :

@media screen and (max-width: 650px) {
    .imgleft {
        background-image: none;
    }
}

(see this Fiddle for a demo)

If you don't want either any background-color or any background-image, you could also do this :

@media screen and (max-width: 650px) {
    .imgleft {
        background-color: transparent;
        background-image: none;
    }
}

(see this Fiddle for a demo)

... or this :

@media screen and (max-width: 650px) {
    .imgleft {
        background: transparent;
    }
}

(see also this Fiddle)

John Slegers
  • 45,213
  • 22
  • 199
  • 169