Advertisement
d4rky

menu cutting

Jan 11th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2. $hover = -50;
  3. $active = -100;
  4. $names = array(
  5.     'start' => 90,
  6.     'fotogalerie' => 120,
  7.     'videogalerie' => 44,
  8.     'magazyn' => 91,
  9.     'zlot' => 77,
  10.     'konkursy' => 41,
  11.     'kontakt' => 12
  12. );
  13.  
  14. $prefix = '.top ul.menu li';
  15. $suffix = 'a';
  16.  
  17. $padding = max(array_map('strlen', array_keys($names))) + strlen($prefix) + strlen($suffix) + 10;
  18.  
  19. $current_width = 0;
  20. foreach($names as $name => $w)
  21. {
  22.     echo str_pad($prefix.'.'.$name.' '.$suffix.'        ', $padding, ' ', STR_PAD_RIGHT).' { background-position: ' . $current_width . 'px 0px; width: ' . $w . 'px; }'."\n";
  23.     echo str_pad($prefix.'.'.$name.' '.$suffix.':hover  ', $padding, ' ', STR_PAD_RIGHT).' { background-position: ' . $current_width . 'px ' . $hover . 'px;'."\n";
  24.     echo str_pad($prefix.'.'.$name.' '.$suffix.'.active ', $padding, ' ', STR_PAD_RIGHT).' { background-position: ' . $current_width . 'px ' . $active . 'px;'."\n";
  25.     echo "\n";
  26.     $current_width -= $w;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement