JSFiddle - React, Tailwind, and code Playground
by Eli Marudi
HTML
<script src=" https://cdnjs.cloudflare.com/ajax/libs/jQuery.print/1.5.0/jQuery.print.js"></script>
<div class="stitched" id="coupon">
<img src="http://greenskyhr.com/wp-content/uploads/2016/08/Logo-wo-Words-tiny2.png" class="coupon__image">
<div class="coupon__headline">
Coupon 1 Example
</div>
<hr class="coupon_hr">
<div class="coupon__body">
Print this coupon and present to field consultant at the beginning of the consultation.
</div>
<div class="coupon__end">
Expires Dec 31, 2016 <br>
Not valid with any other offer. Valid only at participating Green NRG locations.
</div>
</div>
<div class="stitched" id="coupon">
<img src="http://greenskyhr.com/wp-content/uploads/2016/08/Logo-wo-Words-tiny2.png" class="coupon__image">
<div class="coupon__headline">
Coupon 2 Example
</div>
<hr class="coupon_hr">
<div class="coupon__body">
Print this coupon and present to field consultant at the beginning of the consultation.
</div>
<div class="coupon__end">
Expires Dec 31, 2016 <br>
Not valid with any other offer. Valid only at participating Green NRG locations.
</div>
</div>
CSS
.stitched {
width: 22vw;
padding: 20px;
margin: 10px;
background: #ffffff;
color: #2f0000;
font-size: 21px;
font-weight: bold;
line-height: 1.3em;
border: 2px dashed #fff;
border-radius: 10px;
box-shadow: 0 0 0 4px #ffffff, 2px 1px 6px 4px rgba(10, 10, 0, 0.5);
text-shadow: -1px -1px #e8e8e8;
font-weight: normal;
text-align: center;
-webkit-transition: all 0,2s ease;
-moz-transition: all 0,2s ease;
-o-transition: all 0,2s ease;
-ms-transition: all 0,2s ease;
transition: all 0,2s ease;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
transition: all 0.5s ease;
}
JavaScript
$( document ).ready(function() {
$( ".stitched" ).click(function() { // When someone clicks on a div with class "stitched"
var self = this; // Assign the current element (the one that got clicked) to another var, self.
$(this).css("width", "90%"); // Enlarge the div clicked on.
$(".stitched").each(function(i) { // loop through all divs that have a class named "stitched"
if (this != self) { // if the current div in the loop is not the one clicked
$(this).css("display", "none"); // Then hide it.
}
});
$(this).print({ // print the div (using jquery.print.js)
globalStyles: true // Keep existing div styling (css)
});
$(this).css("width", "22vw");
$(".stitched").each(function(i) { // loop again through elements and un-hide them.
$(this).css("display", "block");
});
});
});