css如何自己制作日历

html-css031

css如何自己制作日历,第1张

日历和时间代码:(加在空白处)

#header div.lc{background:url(http://danjo.ca/cgi-sys/Count.cgi?display=date&dformat=yymmdd&ft=0&dd=cd&timezone=GMT+0800) no-repeat 95% 30% !importantfilter:Chroma(Color="#EE0000")DropShadow(Color=gray, OffX=3, OffY=3, Positive=true) !important}/*日期*/

#header div.rc{background:url(http://danjo.ca/cgi-sys/Count.cgi?display=clock&tformat=24&ft=0&dd=cd&timezone=GMT+0800) no-repeat 95% 60%}

.stage{background:url() } /*时间*/

我这里有一段js动态时钟的代码,日历的比较复杂,没有研究:

<scripttype="text/javascript">

setInterval(function() {

var week

var date

var today = new Date()

var year = today.getFullYear()

var month = today.getMonth() + 1

var day = today.getDate()

var ss = today.getDay()

var hours = today.getHours()

var minutes = today.getMinutes()

var seconds = today.getSeconds()

date = year + "年" + month +"月" + day + "日 "

if (ss == 0) week = "星期日"

if (ss == 1) week = "星期一"

if (ss == 2) week = "星期二"

if (ss == 3) week = "星期三"

if (ss == 4) week = "星期四"

if (ss == 5) week = "星期五"

if (ss == 6) week = "星期六"

if (minutes <= 9) minutes ="0" + minutes

if (seconds <= 9) seconds ="0" + seconds

document.getElementById('p_time').innerHTML = "今天是:" + date

+ week + " " + hours + ":" + minutes + ":" +

seconds

},

1000)

</script>

这里一定要注意,html里要有一个id为p_time的div。

自己创建一个日历控件岂不是麻烦?站在巨人的肩上岂不是更好?如果是用于学习倒也可以,如果是项目运用,可以用my97datepicker 或者 jquery ui 的datepicker,都很好用的 :)