Skip to content

Instantly share code, notes, and snippets.

@shinnn
Last active December 10, 2015 21:58
Show Gist options
  • Save shinnn/4498397 to your computer and use it in GitHub Desktop.
Save shinnn/4498397 to your computer and use it in GitHub Desktop.
<?php
function cssSprite($singleWidth, $singleHeight, $verticalNum, $horizontalNum, $elementNum){
echo " style='background:";
echo -floor($elementNum * ceil(1 / $verticalNum)) * $singleWidth, "px ";
echo -$elementNum % $horizontalNum * $singleHeight, "px ";
echo "url(******.jpg) no-repeat;'";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment