Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Getting out of nested SASS easily

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #169062
    jonnow
    Participant

    Hi,

    I’m going to implement svg fallbacks for ie using modernizr (see Chris Coyier’s technique at https://css-tricks.com/svg-fallbacks/) which in short is:

    `.my-element {
      background-image: url(image.svg);
    }
    .no-svg .my-element {
      background-image: url(image.png);
    }
    `
    
    However, as I've nested rules with SASS, I'm wondering if there's an easy way to check for the .no-svg class from within a nest? That is, so I don't have to go through and write out a load of CSS (I'm trying to be as lazy as possible!)
    

    Here’s an example of my SASS at the moment:

    <code></code>.side-nav {
        nav {
            #nav-blog {
                  &amp;:before {
                    background:url(../img/nav/blog.svg) no-repeat 0 8px;
                  }
           }
      }
    }
    
    `
    `
    

    It would be great if I could just write something like:

        `.side-nav {
                    nav {
                        #nav-blog {
                              &amp;:before {
                                background:url(../img/nav/blog.svg) no-repeat 0 8px;
                              }
                        &amp; .. .no-svg &amp;:before {
                            New code here
                        }
                       }
                  }
            }`
    

    Any ideas would be appreciated! Thanks,

    Jonno

    #169063
    Paulie_D
    Member

    Just to clarify in my mind.

    What does .no-svg actually mean?

    If you are saying that it doesn’t support SVG images them surely adding the properties in the right order would solve that?

    .my-element {
    background-image: url(image.png);
      background-image: url(image.svg);
    }
    

    On the other hand if .no-svg means something else that’s a whole other issue.

    #169065
    jonnow
    Participant

    Modernizr carries out the feature detection, if the browser (in this case IE8) doesn’t support svg it adds a class of .no-svg to the…<html> tag.

    Let me give that a try…

    …ok so I gave that a go but with no luck. I tried taking out the position and repeat in the long hope it would fix it but it hasn’t. Looks like IE is just overwriting the .png with the .svg.

    #169068
    Paulie_D
    Member

    Yeah but my question was…”what does .no-svg actually detect.

    Inline SVG elements or .svg images?

    As far as I know `.svg’ is fine for IE9+ : http://caniuse.com/#feat=svg-img

    #169074
    jonnow
    Participant

    Not actually sure to be honest. There is another rule apparently, by the name of .no-inline-svg

    Unfortunately I’m having to support 7+ D:

    Thanks

    #169077
    Paulie_D
    Member

    Unfortunately I’m having to support 7+ D:

    Runs away screaming…

    Wait…so no PNG either..or was that IE6?

    Insofar as this is a SASS question I don’t think you can apply a ‘parent’ (as it were) class within a specificiation… but I’d have to check.

    #169078
    jonnow
    Participant

    Pngs seem to be working fine on IE7 and 8

    #169079
    jonnow
    Participant

    I think they work in 7 but they’re not without [opacity] issues.

    #169080
    Paulie_D
    Member
Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Other’ is closed to new topics and replies.