treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Modernizr, use generated class or not ?

  • hi,

    starting with Modernizr
    http://codepen.io/krsiakdaniel/pen/9/7


    what is correct use to target older browsers, using the default generated class in HTML (example 1.]) ?
    <h1 class="box">Test border shadow</h1>

    /* 1.] uses HTML classes */
    .no-borderradius .box {border: 3px solid green;}
    .borderradius .box {
    -webkit-box-shadow: inset 0 0 5px #333;
    box-shadow: inset 0 0 5px #333;
    }

    /* 2.] but this works too */
    .box {border: 10px solid red;}
    .boxshadow .box {
    border: none;
    -webkit-box-shadow: inset 0 0 5px #333;
    box-shadow: inset 0 0 5px #333;
    }


    I noticed you can use only class .box for older IE
    then just override it in modern browsers, supporting this feature.boxshadow .box with border: none;

    which one of these is correct use?
    (I believe no.1)
  • QUESTION 2

    what to use Modernizr for?
    simple CSS styling stuff can be achieved without it like

    <!--[if IE 7]><html lang="cs" class="no-js ie7 oldie"><![endif]-->
    .ie7 #content {border: 1px solid #000;}
  • this is where I found it 1st time and it is slightly confusing to me
    http://uablogs.missouri.edu/wp-content/presentations/css3/13.2-modernizr.php
  • I never got into using Modernizr, but for question 2, rather then just applying a border, you can actually have modernizr create the box shadow for the user using java instead of a fallback.