色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php創(chuàng)建sprite

復(fù)制代碼 代碼如下:
<?php
$srcdir='./image/';
$prefix="pic11_";
$dst="image";
$imagedir=scandir($srcdir);
array_shift($imagedir);
array_shift($imagedir);
$width=0;
$height=0;
foreach ($imagedir as $key => $value) {
 $picinfo=getimagesize($srcdir.$value);
 $width=$picinfo[0]+$width;
 if ($height<$picinfo[1]) {
  $height=$picinfo[1];
 }
}
$image=imagecreatetruecolor($width,$height);
imagesavealpha($image, true);
$color=imagecolorallocatealpha($image,0,0,0,127) ;
imagefill($image, 0, 0, $color);
$width=0;
$height=0;
$css="";
foreach ($imagedir as $key => $value) {
 $picinfo=getimagesize($srcdir.$value);
 $im=imagecreatefrompng($srcdir.$value);       //創(chuàng)建image
 imagecopymerge($image, $im, $width, 0, 0, 0, $picinfo[0], $picinfo[1],100);
 $picname=pathinfo($srcdir.$value);
 $css=".".$prefix.$picname['filename']."{height:".$picinfo[0]."px;width:".$picinfo[1]."px;background-position: -".$width."px 0px;}".$css;
 $width=$width+$picinfo[0];
 imagedestroy($im);             //銷毀image
}
$css=$css."[class*=".$prefix."]{background-image:url('image.png');}}";
$css=$css.".".$prefix."{background-image:url('image.png');}";  //兼容ie 系列
file_put_contents("./".$dst.'.css',$css);
imagepng($image,"./".$dst.'.png');
imagedestroy($image);
?>

<link rel="stylesheet" type="text/css" href="./image.css">
<!-- <img src="./image.png"> -->
<body style="background-color:#eee">
 <div class="pic11_css3">
</div>
<div class="pic11_firefox">
</div>
<div class="pic11_chrome">
</div>
<span class="css3">

</span>
<span class="sprite firefox">
</span>
</body>

php技術(shù)php創(chuàng)建sprite,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 虹口区| 衡阳市| 长宁县| 茶陵县| 安塞县| 自贡市| 东莞市| 新营市| 白玉县| 长泰县| 淳化县| 临海市| 昔阳县| 温宿县| 舟曲县| 鄢陵县| 内江市| 海门市| 宣化县| 潼关县| 伊川县| 高阳县| 定陶县| 治多县| 伊吾县| 沂源县| 南丰县| 威远县| 石楼县| 永新县| 千阳县| 交城县| 吉安县| 吉水县| 武冈市| 寻甸| 望都县| 阿克陶县| 新营市| 海伦市| 措美县|