Skip to content

Sprites inside @media queries #617

@dbanck

Description

@dbanck

I'm using sprites inside a @media screen and (max-width: 480px) query.

But the generated CSS will apply to all elements and not only those inside the media-query. So it will override my other sprite.

Example:
main.sass:

body

  #main-navigation
    background: inherit

    .home-button
      +icons-sprite(navigation-home)

_mobile.sass:

@import sprites/mobile

@media screen and (max-width: 480px)
  body
    overflow: auto

    #main-navigation
      background: none

      .home-button
        +mobile-sprite(navigation-home)

The generated CSS looks like this:

.icons-sprite, body #main-navigation .home-button {
  background: url('/images/icons-sf5e32584e9.png') no-repeat;
}

.mobile-sprite, body #main-navigation .home-button {
  background: url('/images/mobile-s32b9a3f1df.png') no-repeat;
}

@media screen and (max-width: 480px) {
  body #main-navigation .home-button {
    background-position: 0 -116px;
  }
}

So the second sprite will override the first one, even if it's just indented for mobile usage.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions