Default|0Aero|1Caphy|2LAmour|3Dre-S|4Obsid|5Toba|6NoStyle|100
2008 12月 16
三段PHP代码

三段PHP代码

  无聊时候写的三段PHP代码,纯粹是写着玩的。

  日历查看效果
<style>
body {
    font: 12px Verdana, Arial, Helvetica, sans-serif;
}
.cal {

    width: 196px;
}
.cal_title, .cal_t {

    padding: 2px;
    padding-top: 4px;
    padding-bottom: 4px;
    margin: 1px;
    border: 1px solid #ddd;
    text-align: center;
}
.cal_title {

    font-size: 1.2em;
}
.cal_t {

    width: 20px;
    float: left;
}
.cal_w {

    font-weight: bold;
}
.cal_wd {

    background: #f2f2f2;
}
.cal_td {

    background: #fec;
}
.cal_x {

    color: #ddd;
}
.cal_b {

    text-align: center;
    width: 187px;
    position: absolute;
    z-index: -100;
    color: #dadada;
    font-weight: bold;
    padding: 5px;
}
.cal_y {

    font-size: 2em;
    padding-top: 24px;
}
.cal_m {

    padding-top: 38px;
    font-size: 7em;
}
</style>
<?php

$m=date('n');
$y=date('Y');
$t=mktime(0,0,0,$m,1,$y);
$x=date('t', ($t-86400));
$f=date('w', $t)-1;
echo
'<div class="cal_y cal_b">'.$y.'</div><div class="cal_m cal_b">'.$m.'</div><div class="cal"><div class="cal_t cal_w cal_wd">S</div><div class="cal_t cal_w">M</div><div class="cal_t cal_w">T</div><div class="cal_t cal_w">W</div><div class="cal_t cal_w">T</div><div class="cal_t cal_w">F</div><div class="cal_t cal_w cal_wd">S</div>';
for
($i=0;$i<date('t',$t)+$f+1;$i++)echo '<div class="cal_t cal_d'.((($i-$f)==intval(date('d')) && $m==date('n') && $y==date('Y'))?' cal_td':'').(($i%7==0 || $i%7==6)?' cal_wd':'').($i>$f?'':' cal_x').'">'.($i>$f?($i-$f):($x+$i-$f)).'</div>';
if(
$i%7>0){
    for(
$j=0;$j<(7-$i%7);$j++)echo '<div class="cal_t cal_d cal_x">'.($j+1).'</div>';
}
echo
'</div>';
?>


  随机色彩查看效果
<style>
.co_div {
    width: 20px;
    height: 20px;
    float: left;
    margin-right: 1px;
    margin-top: 1px;
}
</style>
<?php
function a(
$r, $a){
    foreach(
$r as $k=>$v)$n[$k]=$v+(255-$v)*$a/100;
    return sprintf(
&#039;#%02X%02X%02X&#039;, $n[0], $n[1], $n[2]);
}

$m=150;
$a[]=rand($m,255);
$a[]=rand($m,255);
$a[]=rand($m,255);
if(min(
$a)>240)$a[rand(0,2)]=rand($m, 240);
for(
$i=0;$i<2000;$i++){
    $ta=rand(0,100);
    echo
&#039;<div class="co_div" style="background: &#039;.a($a, $ta).&#039;;"></div>&#039;;
}
?>


  色彩列表查看效果
<style>
.co_t {
    width: 400px;
}
.co_div {

    width: 20px;
    height: 20px;
    float: left;
    margin-right: 1px;
    margin-top: 1px;
}
</style>
<?php

$a=array(array(&#039;0&#039;, &#039;3&#039;, &#039;6&#039;), array(&#039;9&#039;, &#039;c&#039;, &#039;f&#039;));
$b=array(&#039;0&#039;, &#039;3&#039;, &#039;6&#039;, &#039;9&#039;, &#039;c&#039;, &#039;f&#039;);
$c=array(&#039;0&#039;, &#039;3&#039;, &#039;6&#039;, &#039;9&#039;, &#039;c&#039;, &#039;f&#039;);
echo
&#039;<div class="co_t">&#039;;
foreach(
$a as $ka=>$va){
    foreach(
$b as $vb){
        echo
&#039;<div class="co_div" style="background: #&#039;.$vb.$vb.$vb.&#039;;"></div>&#039;;
        foreach(
$va as $v){
            foreach(
$c as $vc){
                $t=$v.$vb.$vc;
                echo
&#039;<div class="co_div" style="background: #&#039;.$t.&#039;;"></div>&#039;;
            }
        }
    }
}
echo
&#039;</div>&#039;;
?>



发表评论

  留言系统暂不可用,请稍后再试。本站留言系统通过限制IP、设置留言时间间隔、自动关闭就日志评论等方式防止垃圾留言,造成不便,请见谅!