$dark: #000; $light: #FFF; $size: 55px; body { margin: 0; padding: 0; } .container { width: 100%; position: absolute; top: 0; bottom: 0; display: -webkit-flex; display: flex; align-items: center; justify-content: center; } .squares { width: 16*$size; height: 14*($size+4px); overflow: hidden; } .block, .block:after { width: $size; height: $size; background: $dark; padding-left: $size; content: ""; float: left; position: relative; } .block:after { background: $light; position: absolute; left: $size; top: 0; } .row { border-top: 4px solid lighten($dark, 30%); height: $size; width: 150%; -webkit-animation: EXPAND 5s infinite; animation: EXPAND 5s infinite; -webkit-animation-delay: 5s; animation-delay: 5s; } .row:nth-last-child(1) { border-bottom: 4px solid lighten($dark, 30%); } .row:nth-child(2n) { padding-left: 0.6*$size; } @-webkit-keyframes EXPAND { 50% { padding-left: 0px; } } @keyframes EXPAND { 50% { padding-left: 0px; } } @import url(http://fonts.lug.ustc.edu.cn/css?family=Open+Sans); .caption { background: $light; color: $dark; position: absolute; top: 0px; left: 0px; z-index: 100; font-size: 2em; text-align: center; width: 100%; font-family: Open Sans, sans-serif; }