Be the first to write a review
Free! - PHP and CSS: random images and CSS positioning
Until recently I was unaware of the power of CSS and Its ability to integrate with other languages. I always thought that styles were static and had to be coded into the style sheet.
It was with a visit to A List Apart when I stumbled across a PHP article about Random Images by Dan Benjamin. As I’m only a newcomer to PHP, I was interested enough to read on and found it to be a great article & script. Another blog style site Relatively Absolute is a perfect working example of the Image rotation script as it uses one for generating random header images much like the ones I’m going to be demonstrating here. In fact Absolutely Relative inspired me to write this article because I liked the transparency illusion so much.
Summary
In this article I have demonstrated how to take CSS a step further by integrating it with a PHP script. This is just the tip of the iceberg if you think about the options we went over in the configuration of the randomise script. You could tweak the code to display a random .pdf in your page, or to call a different style sheet each time the page refreshes. There are many options available.
Author’s Notes
I hope you find this article easy to understand and useful for some future design ideas you may have. I’ve recently ‘jumped ship’ from ASP over to PHP mainly due to the fact that most hosts now offer mySQL free so I’m busy playing around with the new options PHP has given me.
Many thanks to A List Apart and Dan Benjamin for permission to reprint the Random Image Script.
Enjoy, and please rate our articles if you read them.