随机化背景图像
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了随机化背景图像相关的知识,希望对你有一定的参考价值。
Set up and array of filenames, which correspond to the file names of the images you are trying to randomize.
<?php $bg = array('bg-01.jpg', 'bg-02.jpg', 'bg-03.jpg', 'bg-04.jpg', 'bg-05.jpg', 'bg-06.jpg', 'bg-07.jpg' ); // array of filenames $selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen ?> <style type="text/css"> <!-- body{ background: url(images/<?php echo $selectedBg; ?>) no-repeat; } --> </style>
以上是关于随机化背景图像的主要内容,如果未能解决你的问题,请参考以下文章