JSFiddle - React, Tailwind, and code Playground

by Marventus

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<div class="board row-flexible">
</div>

<a id="flip">Girar todas</a>

SCSS

.board {
  width: 600px;
  height: 600px;
  margin: 0 auto;
  background: #ede9d9;
  border: 4px solid red;
}

.col-xs-3 {
  margin-bottom: 10px;
}

.flip-container {
	perspective: 1000;
  position: relative;
}
	/* flip the pane when hovered */
	.flip-container:hover .flipper, .flip-container.active .flipper , .flip-container.hover .flipper {
		transform: rotateY(180deg);
	}

.flip-container, .front, .back {
	width: 90px;
  height: 120px;
}

/* flip speed goes here */
.flipper {
	transition: 0.6s;
	transform-style: preserve-3d;

	position: relative;
}

/* hide back of pane during swap */
.front, .back {
	backface-visibility: hidden;
  width: 90px;
  height: 120px;
  border: 1px solid black;
  border-radius: 5px;
  margin: 13px auto;

	position: absolute;
	top: 0;
	left: 0;
}

/* front pane, placed above back */
.back {
	z-index: 2;
	/* for firefox 31 */
	transform: rotateY(0deg);
}

/* back, initially hidden pane */
.front {
	transform: rotateY(180deg);
}

.back {
  background: white;
  background: repeating-linear-gradient(
    45deg,
    #a12f02,
    #a12f02 5px,
    transparent 5px,
    #FFF 10px
  ), repeating-linear-gradient(
    -45deg,
    #a12f02,
    #a12f02 5px,
    transparent 5px,
    #FFF 10px
  );
}

.front {
  background: white;
}

/* START: Centrar personajes dentro de la carta */
.front {
  text-align: center;
  white-space: nowrap;
}
.front:before {
  content: '';
  display: inline-block;
  height: 100%;
  vertical-align: middle;
  margin-right: -0.25em; /* Adjusts for spacing */
}
.front span {
  display: inline-block;
  vertical-align: middle;
}
/* END: Centrar */

JavaScript

function mezclarArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
    return array;
}
function insertarCartasHTML(cartas, html, contenedor) {
	contenedor = $(contenedor);
	$.each(cartas, function(i,v){
    	contenedor.append( html.replace("**cartaNombre**", v) );
    });
}

$('document').ready(function() {
    var cartas = ['Policia', 'Ladron', 'Medico', 'Pueblo', 'Pueblo', 'Pueblo', 'Pueblo', 'Pueblo'],
        cartasMezcladas = mezclarArray(cartas),
        cartasHtml = ['<div class="col-xs-3 col-sm-offset-2">',
            '<div class="flip-container">',
            '<div class="card flipper">',
            '<div class="back"></div>',
            '<div class="front">',
            	'<span>**cartaNombre**</span>',
            '</div>',
            '</div>',
            '</div>',
            '</div>'
        ].join("");
    	insertarCartasHTML(cartasMezcladas, cartasHtml, ".board");

    $('#flip').on('click', function() {
        $('.flip-container').toggleClass('active');
    });
    
});