[thelist] generating random image in css
Paul Cowan
evolt at funkwit.com
Wed Jun 8 19:19:49 CDT 2005
On 8/06/2005 10:42 PM +0100 Chris Hayes wrote:
> I use CF to run dynamic css files for these things..
>
> The css link ref points to a cfm file which sets content output to
> text/css and includes the css file with with the dynamic vars coded into
> the image url.
>
> If you can't do this with ASP you can use the style attribute of the div
> to randomly set the background image.
Yeah, you can do this with asp. Instead of pointing at foo.css as your
stylesheet, point at foo.asp. Make the first 4 lines of foo.asp:
<%
response.contenttype = "text/css"
response.expires = 15
%>
(well, the third line can be whatever timeout you like; but if you don't
have one, the CSS will be rerequested every page view as ASP pages by
default are not cacheable)
Then put your CSS as normal, and have
div.header {
background-image: <% response.write SomeRandomImage %>;
}
Easy!
Cheers,
Paul
More information about the thelist
mailing list