CodeHQ

WordPress OEmbed – responsive video

Adds a container around iframes to allow responsive video when utilising WordPress OEmbed functionality.

jQuery

$("iframe").wrap("<div class='iframe-container'/>");

SCSS

.iframe-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    iframe {
        position: absolute;
        top:0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

Original source

Pulsing heart | CSS

.heart {
    position: relative;
    width: 34px;
    overflow: inherit;
    -webkit-animation: animateHeart 2.5s infinite;
    animation: animateHeart 2.5s infinite;
}
.heart:before,
.heart:after {
   position: absolute;
   content: '';
   top: 0;
   left: 17px;
   width: 17px;
   height: 27px;
   background: #3C948B;
   border-radius: 50px 50px 0 0;
   -webkit-transform: rotate(-45deg) translateZ(0);
   transform: rotate(-45deg) translateZ(0);
   -webkit-transform-origin: 0 100%;
   transform-origin: 0 100%;
}
.heart:after {
   left: 0;
   -webkit-transform: rotate(45deg) translateZ(0);
   transform: rotate(45deg) translateZ(0);
   -webkit-transform-origin: 100% 100%;
   transform-origin :100% 100%;
}

@-webkit-keyframes animateHeart {
  0%  { -webkit-transform: scale(1); }
  5%  { -webkit-transform: scale(1.2); }
  10% { -webkit-transform: scale(1.1); }
  15% { -webkit-transform: scale(1.3); }
  50% { -webkit-transform: scale(1); }
  100% { -webkit-transform: scale(1); }
}
@keyframes animateHeart {
  0%  { transform: scale(1); }
  5%  { transform: scale(1.2); }
  10% { transform: scale(1.1); }
  15% { transform: scale(1.3); }
  50% { transform: scale(1); }
  100% { transform: scale(1); }
}

Image alignment properties in WordPress

Add this to your CSS to allow align left, right, center and none to images in WordPress posts and pages.

.alignright {
	float: right;
	padding: 10px 0px 10px 10px;
}
.alignleft {
	float: left;
	padding: 10px 10px 10px 0px;
}
.aligncenter {
	clear: both; 
	display: block; 
	margin-left: auto; 
	margin-right: auto;
	padding: 10px;
}
.alignnone {
	padding: 10px 0;
}

Pure CSS Checkbox Image replacement

Use this method for replacing a standard checkbox input with an image or styled box.

The markup

<input type='checkbox' name='thing' value='valuable' id="thing"/><label for="thing"></label> 

The CSS

input[type=checkbox] {
    display:none;
}
input[type=checkbox] + label {
    background: #999; //colour or image
    height: 16px;
    width: 16px;
    display:inline-block;
    padding: 0 0 0 0px;
}
input[type=checkbox]:checked + label {
    background: #0080FF; //colour or image
    height: 16px;
    width: 16px;
    display:inline-block;
    padding: 0 0 0 0px;
}

Responsive tables

Original article

Add this in to a media query and you’ll be sweet. Adjust as necessary for padding/colours/fonts.

@media 
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px)  {

	/* Force table to not be like tables anymore */
	table, thead, tbody, th, td, tr { 
		display: block; 
	}
	
	/* Hide table headers (but not display: none;, for accessibility) */
	thead tr { 
		position: absolute;
		top: -9999px;
		left: -9999px;
	}
	
	tr { border: 1px solid #ccc; }
	
	td { 
		/* Behave  like a "row" */
		border: none;
		border-bottom: 1px solid #eee; 
		position: relative;
		padding-left: 50%; 
	}
	
	td:before { 
		/* Now like a table header */
		position: absolute;
		/* Top/left values mimic padding */
		top: 6px;
		left: 6px;
		width: 45%; 
		padding-right: 10px; 
		white-space: nowrap;
	}
	
	/*
	Label the data
	*/
	td:nth-of-type(1):before { content: "First Name"; }
	td:nth-of-type(2):before { content: "Last Name"; }
}

Disables scrolling with the mouse wheel on Google map

Original article

Solved this putting a div with an .overlay exactly before each Google map iframe insertion. The div will cover the map, preventing pointer events from getting to it. But if you click on the div, it becomes transparent to pointer events, activating the map again!

The markup

<html>
  <div class="overlay" onClick="style.pointerEvents='none'"></div>
  <iframe src="https://mapsengine.google.com/map/embed?mid=some_map_id" width="640" height="480"></iframe>
</html>

The CSS

.overlay {
   background:transparent; 
   position:relative; 
   width:640px;
   height:480px; /* your iframe height */
   top:480px;  /* your iframe height */
   margin-top:-480px;  /* your iframe height */
}

Update:
There is a jQuery solution for this if you do not embed the map via iFrame.

$(function() {
    $('#map').click(function(e) {
        $(this).find('.gm-style').css('pointer-events', 'all');
    }).mouseleave(function(e) {
        $(this).find('.gm-style').css('pointer-events', 'none');
    });
})

And a little bit of CSS

.gm-style {
	pointer-events: none;
}