 body {
    margin: 0;
    padding: 0;
    background: #EEE;
    font: 10px/13px 'Lucida Sans',sans-serif;
}
.wrap {
    overflow: hidden;
    margin: 10px;
  max-width: 1500px;
  margin-left: auto;
  margin-right: auto;
}
.box {
    float: left;
    position: relative;
    width: 20%;
    padding-bottom: 20%;
}

.boxInner {
    position: absolute;
    left: 10px;
    right: 10px;
    top: 10px;
    bottom: 10px;
    overflow: hidden;
}
 .boxInner img { width: 100% }


@media only screen and (max-width:480px) { 
    /* Smartphone view: 1 tile */
    .box {
        width: 100%;
        padding-bottom: 100%;
    }
}
@media only screen and (max-width:650px) and (min-width:481px) { 
    /* Tablet view: 2 tiles */
    .box {
        width: 50%;
        padding-bottom: 50%;
    }
}
@media only screen and (max-width:1050px) and (min-width:651px) { 
    /* Small desktop / ipad view: 3 tiles */
    .box {
        width: 33.3%;
        padding-bottom: 33.3%;
    }
}
@media only screen and (max-width:1290px) and (min-width:1051px) { 
    /* Medium desktop: 4 tiles */
    .box {
        width: 25%;
        padding-bottom: 25%;
    }
}