Advertisement
Guest User

mmmmm

a guest
May 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. function create_css(&$tab){
  2. $all_values = [];
  3. if (!file_exists('style.css')) {
  4. for ($i = 0; $i < count($tab); $i++) {
  5. $tmp = getimagesize($tab[$i]);
  6. array_push($all_values, $tmp);;
  7. $path = explode("/", $tab[$i]);
  8. $path = end($path);
  9. $path =str_replace(".","_" ,$path );
  10. static $back_pos = 0;
  11. $height = "#" .$path. "{\n"."width :".$all_values[$i][0]."px;\n"
  12. ."height :".$all_values[$i][1]."px;\n"."display:inline-block;\n"
  13. ."background-repeat: no-repeat; \n"
  14. ."background-position: -" .$back_pos ." 0px; \n"
  15. ."background-image: url('sprite.png');" ."\n}" ."\n \n" ;
  16. $back_pos += $all_values[$i][0];
  17. file_put_contents('style.css', $height, FILE_APPEND);
  18. }
  19. }
  20. else if(file_exists('style.css')){
  21. unlink('style.css');
  22. create_css($tab);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement