All Posts in Code Snippets

Quick way to highlight images without alt tags

Quick way to highlight all images without/with empty alt tags via CSS: /* No alt tag */ img:not([alt]){ outline: 1px solid red !important; } /* Empty alt tag */ img[alt=""]{…

jQuery Check if Element Exists

Very simple method to check if an element exists using jQuery. Throw the following code at the beginning of your script: jQuery.fn.exists = function(){ return this.length > 0; }…

Spinning Newspaper CSS3 Animation

.spinning{ -webkit-transform: rotate(0deg); -moz-transform: rotate(0deg); transform: rotate(0deg); -webkit-animation-duration: 1s; -webkit-animation-iteration-count: 1; -webkit-animat…

How to centre absolutely positioned elements on screen

If you want to place absolutely positioned elements in the middle of the screen just do the following: #some_div{ width: 150px; height: 100px; position: absolute; top: 50%; …

nth-child Fix for IE 8 and lower

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <!--[if lte IE 8]> <script type="text/javascript"> $(document).ready(function() { …