Php 更改任何特定日期列的日期颜色?
如何将“星期日”日期列设置为红色。虽然使用“colgroup”只能更改背景颜色,但如何更改一列的日期颜色,即星期日。如果我们谈论今天的日期,那么把日期“4”、“11”、“18”、“25”的颜色改成红色。请帮忙。。。谢谢 CALENDAR.PHPPhp 更改任何特定日期列的日期颜色?,php,html,Php,Html,如何将“星期日”日期列设置为红色。虽然使用“colgroup”只能更改背景颜色,但如何更改一列的日期颜色,即星期日。如果我们谈论今天的日期,那么把日期“4”、“11”、“18”、“25”的颜色改成红色。请帮忙。。。谢谢 CALENDAR.PHP <!doctype html> <html> <head> <style> a { text-decoration: none; } </style> </head> <bod
<!doctype html>
<html>
<head>
<style>
a
{
text-decoration: none;
}
</style>
</head>
<body>
<h1 style=" margin-left: 608px; color:brown; ">Calendar (PHP)</h1>
<?php
$monthNames = Array("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December");
if (!isset($_GET["month"]))
{
$_GET["month"]=date("n");
}
if (!isset($_GET["year"]))
{
$_GET["year"]=date("Y");
}
$current_month=$_GET["month"] ;
$current_year=$_GET["year"] ;
$prevous_month=$current_month-1;
$next_month=$current_month+1;
$prevous_year=$current_year-1;
$next1_year=$current_year+1;
$prev_year=$current_year;
$next_year=$current_year;
if( $prevous_month == 0 )
{
$prevous_month= 12;
$prev_year=$current_year-1;
}
if( $next_month == 13 )
{
$next_month=1;
$next_Year=$current_year+1;
}
echo "<table style='margin-top: 50px; margin-left: 586px;'>
<tr>
<td colspan=1 align='center' style='color:pink'><button> <a href=". "?year=" . $prevous_year." ><<</a></button></td>
<td colspan=1 align='center'> <button><a href="."?month=".$prevous_month."&year=".$prev_year."><</a></button></td>
<td colspan=3 align='center'><button > <a href= "."?month=".date('m')."&year=".date('Y')."> Today Date </button></td>
<td colspan=1 align='center'><button> <a href=". "?month=".$next_month. "&year=" . $next_year.">></a></button></td>
<td colspan=1 align='center'><button> <a href=" ."?year=" . $next1_year.">>></a></button></td>
</tr>
<tr>
<td></td><td></td><td colspan=3 align=center style='color:green'>".date('d').", ".$monthNames[$current_month-1].", ". $current_year."</td>
</tr>
<tr>
<td align='center' style='color:red'>Sun</td>
<td align='center' style='color:blue'>Mon</td>
<td align='center' style='color:blue'>Tue</td>
<td align='center' style='color:blue'>Wed</td>
<td align='center' style='color:blue'>Thu</td>
<td align='center' style='color:blue'>Fri</td>
<td align='center' style='color:blue'>Sat</td>
</tr>";
$time = mktime(0,0,0,$current_month,1,$current_year);
$totle_day = date("t",$time);
$thismonth = getdate ($time);
$startday = $thismonth['wday'];
for ($i=0; $i<($totle_day+$startday); $i++)
{
if(($i % 7) == 0 )
echo "<tr>";
if($i < $startday)
echo "<td></td>";
else
echo "<td align='center' >". ($i - $startday +1) . "</td>";
if(($i % 7) == 6 )
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>
A.
{
文字装饰:无;
}
日历(PHP)
试试这个
for ($i=0; $i<($totle_day+$startday); $i++)
{
if(($i % 7) == 0 )
echo "<tr>";
if($i < $startday)
echo "<td></td>";
else if(($i % 7) == 0 )
echo "<td align='center' style='color:red;' >". ($i - $startday +1) . "</td>";
else
echo "<td align='center' >". ($i - $startday +1) . "</td>";
if(($i % 7) == 6 )
echo "</tr>";
}
对于($i=0;$i请这样尝试
为第一列指定一个类名,如sunday
,并为sunday
类指定所需的样式
范例
改变
echo "<td align='center' >". ($i - $startday +1) . "</td>";
方法2:
通过使用此选项,您可以使其更加简单。
给表格一个id,比如说weeks
在样式表中添加以下内容
.sunday
{
color:red;
}
#weeks td:first-child {color: red; }
Thanx#krishna它在起作用……我认为这是最简单的方法……非常感谢……嗯,方法2:更简单的方法……谢谢hanx@AeJey……这也在起作用……你永远都是受欢迎的朋友。:)看看我的方法2
,它会更简单,可以用来设置表中任何第n列的样式
#weeks td:first-child {color: red; }