/ Published in: PHP
dynamic CSS file, where the background style attributes (in this case h2 headers) are auto-created from the files in a particular directory.
1. include the css file as per normal in your
2. create new css.php file
3. add in custom css header - header("Content-type: text/css");
4. create directory full of heading images
5. add in code below
6. will automatically set the background image of "some-header.png" from the image directory
6. win life!
1. include the css file as per normal in your
2. create new css.php file
3. add in custom css header - header("Content-type: text/css");
4. create directory full of heading images
5. add in code below
6. will automatically set the background image of "some-header.png" from the image directory
6. win life!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* all your other CSS rules can go here too! */ h2 { display:block; width:400px; height:30px; background-repeat:no-repeat; } h2 span { display:none; } <? $path = 'headers/'; $dir = $_SERVER['DOCUMENT_ROOT'] . $path; if ($file != "." && $file != "..") { echo 'h2.' . $class . ' { ' . "\n"; echo 'background-image:url("' . $path . $file . '"); ' . "\n"; echo '}' . "\n\n"; } } } ?>