Display Image Next To Each Tag

<?php
$posttags = get_the_tags(); // Get articles tags
$home = get_bloginfo('url'); // Get homepage URL

// Check tagslug.png exists and display it
if ($posttags) {
 foreach($posttags as $tag) {
       $image = "/images/tag-images/$tag->slug.png";

       if (file_exists("images/tag-images/$tag->slug.png")) {
         echo '<a href="' . $home 
Avatar of Chris Coyier
Chris Coyier on

Calculate Distance Between Mouse and Element

(function() {
    
    var mX, mY, distance,
        $distance = $('#distance span'),
        $element  = $('#element');

    function calculateDistance(elem, mouseX, mouseY) {
        return Math.floor(Math.sqrt(Math.pow(mouseX - (elem.offset().left+(elem.width()/2)), 2) + Math.pow(mouseY - (elem.offset().top+(elem.height()/2)), 2)));
    }

    $(document).mousemove(function(e) {  
        mX = e.pageX;
        mY = e.pageY;
        distance = calculateDistance($element, 
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Hexagon with Shadow

<div class="hexagon"><span></span></div>
.hexagon {
  width: 100px;
  height: 55px;
  position: relative;
}

.hexagon, 
.hexagon:before, 
.hexagon:after {
  background: red;
  box-shadow: 0 0 10px rgba(0,0,0,0.8);   
}

.hexagon:before,
.hexagon:after {
  content: "";
  position: absolute;
  left: 22px;
  width: 57px;
  height: 57px;
  transform: rotate(145deg) skew(22.5deg);
}

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Diagonal Graph Paper Gradient

#example-gradient {
  height: 200px;
  margin: 0 0 20px 0;
  background-color: #eaeaea;
  background-size: 20px 20px;
  background-image:
     -webkit-repeating-linear-gradient(45deg, rgba(0, 191, 255, .5), rgba(0, 191, 255, .5) 1px, transparent 1px, transparent 15px),
     -webkit-repeating-linear-gradient(-45deg, rgba(255, 105, 180, .5), rgba(255, 105, 180, .5) 1px, transparent 
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Screen Resolution ≠ Browser Window

The only statistic you get in most web analytics software is screen resolution. But there is a pretty good chance you just read this sentence in a browser that isn't open to the full size of your monitor. If you are looking at size analytics for you website, browser size is far more relevant. In this article we figure out how to get that data, and then look at some of the results gathered from css-tricks.com.
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Dropp

Direct Link

My buddies at Sense Labs just released a really cool iPhone app called Dropp. Allows you to leave location-based messages anywhere on Earth that people receive when they visit that location. Leave them privately for your friends, or publicly. Such …

Avatar of Chris Coyier
Shared by Chris Coyier on

CSS Lint

Direct Link

New tool by Nicholas Zakas and Nicole Sullivan to analyze your CSS and tell you that you are doing a bad job. It’s an amazing tool to help you understand how to write better CSS. To nitpick, I’d say that …

Avatar of Chris Coyier
Shared by Chris Coyier on

The Stats That Matter: Your Site’s Stats

Just because I thought it was interesting, I shared this on Twitter this morning:

95% of traffic to CSS-Tricks has a screen resolution of larger than 1024×768.

And I got all kinds of responses like: That’s such a skewed statistic!!!

Avatar of Chris Coyier
Chris Coyier on