Skip to content

Instantly share code, notes, and snippets.

@cduruk
Created August 10, 2011 01:05
Show Gist options
  • Save cduruk/1135730 to your computer and use it in GitHub Desktop.
Save cduruk/1135730 to your computer and use it in GitHub Desktop.
Box Shadow
/**
* Output CSS3 box shadows
*
* @param string $xOffset The x offset of the shadow
* @param string $yOffset The y offset of the shadow
* @param string $size Size of the shadow
* @param string $opacity You can either specify an opacity value (0 through 1) or a hex color value
* @param string $location You can specify this optionally as 'inset' and the shadow will be inside of the element instead of outside
*
* @return string
*/
public function dropShadow($xOffset = 0, $yOffset = 0, $size = 0, $opacity = 0, $location = '')
{
if (strstr($opacity, '#')) {
$opacity = $opacity;
} else {
$opacity = "rgba(0, 0, 0, {$opacity})";
}
$css = "box-shadow: {$location} {$xOffset} {$yOffset} {$size} {$opacity}; -moz-box-shadow: {$location} {$xOffset} {$yOffset} {$size} {$opacity}; -webkit-box-shadow: {$location} {$xOffset} {$yOffset} {$size} {$opacity};";
return $css;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment