我试图使用此代码结合使用 php 和 css 在 10 个动画之间随机切换。一切正常,除了 rand() 总是显示为“1”,无论我重新加载页面或打开和关闭选项卡多少次。我究竟做错了什么?
<style type="text/css">
#a {width:200; height:200; background-color:black; color:red; font-size:30; position:relative; left:50; top:50;
<?php
$z=mt_rand(1,10);
if ($z="1")
{echo "animation:a 5s linear 1s infinite alternate; -webkit-animation:a 5s linear 1s infinite alternate; -mox-animation:a 5s linear 1s infinite alternate; -o-animation:a 5s linear 1s infinite alternate;";}
elseif($z="2")
{echo "animation:b 5s linear 1s infinite alternate; -webkit-animation:b 5s linear 1s infinite alternate; -mox-animation:b 5s linear 1s infinite alternate; -o-animation:b 5s linear 1s infinite alternate;";}
elseif($z="3")
{echo "animation:c 5s linear 1s infinite alternate; -webkit-animation:c 5s linear 1s infinite alternate; -mox-animation:c 5s linear 1s infinite alternate; -o-animation:c 5s linear 1s infinite alternate;";}
elseif($z="4")
{echo "animation:d 5s linear 1s infinite alternate; -webkit-animation:d 5s linear 1s infinite alternate; -mox-animation:d 5s linear 1s infinite alternate; -o-animation:d 5s linear 1s infinite alternate;";}
elseif($z="5")
{echo "animation:e 5s linear 1s infinite alternate; -webkit-animation:e 5s linear 1s infinite alternate; -mox-animation:e 5s linear 1s infinite alternate; -o-animation:e 5s linear 1s infinite alternate;";}
elseif($z="6")
{echo "animation:f 5s linear 1s infinite alternate; -webkit-animation:f 5s linear 1s infinite alternate; -mox-animation:f 5s linear 1s infinite alternate; -o-animation:f 5s linear 1s infinite alternate;";}
elseif($z="7")
{echo "animation:g 5s linear 1s infinite alternate; -webkit-animation:g 5s linear 1s infinite alternate; -mox-animation:g 5s linear 1s infinite alternate; -o-animation:g 5s linear 1s infinite alternate;";}
elseif($z="8")
{echo "animation:h 5s linear 1s infinite alternate; -webkit-animation:h 5s linear 1s infinite alternate; -mox-animation:h 5s linear 1s infinite alternate; -o-animation:h 5s linear 1s infinite alternate;";}
elseif($z="9")
{echo "animation:i 5s linear 1s infinite alternate; -webkit-animation:i 5s linear 1s infinite alternate; -mox-animation:i 5s linear 1s infinite alternate; -o-animation:i 5s linear 1s infinite alternate;";}
elseif($z="10")
{echo "animation:j 5s linear 1s infinite alternate; -webkit-animation:j 5s linear 1s infinite alternate; -mox-animation:j 5s linear 1s infinite alternate; -o-animation:j 5s linear 1s infinite alternate;";}
?>
}
</style>