Skip to content

Instantly share code, notes, and snippets.

@stphnwlkr
Last active February 24, 2017 17:37
Show Gist options
  • Save stphnwlkr/445dbcbb43d61b1c29be6991e4f53dac to your computer and use it in GitHub Desktop.
Save stphnwlkr/445dbcbb43d61b1c29be6991e4f53dac to your computer and use it in GitHub Desktop.
Random Image for CSS using ColdFusion
<cfoutput>
<cfscript>
imglist = 'bg4.jpg,bg3.jpg,telehealth_hero_1.jpg';
randImg=ArrayNew(1);
randImg = listtoarray(imglist,',');
bgImg=randImg[RandRange(1,ArrayLen(randImg))];
</cfscript>
<style>
.hero {
padding-top: 3rem;
padding-bottom: 3rem;
background-image: url("/_media/img/hero/#bgImg#");
background-position: center;
background-size: cover;
min-height: 400px;
}
</style>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment