用JS在你的網頁上顯示當前時間

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<font color="red"><b>
<script language="JavaScript">
<!--
tmpDate = new Date();
date = tmpDate.getDate();
month= tmpDate.getMonth() + 1 ;
myyear= tmpDate.getYear();
year=(myyear > 200) ? myyear : 1900 + myyear;

document.write(year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日 ");

myArray=new Array(6);
myArray[0]="星期日"
myArray[1]="星期一"
myArray[2]="星期二"
myArray[3]="星期三"
myArray[4]="星期四"
myArray[5]="星期五"
myArray[6]="星期六"
weekday=tmpDate.getDay();
if (weekday==0 | weekday==6)
{
document.write(myArray[weekday])
}
else
{document.write(myArray[weekday])
};

hours = tmpDate.getHours();
minutes = tmpDate.getMinutes();
seconds = tmpDate.getSeconds();
times = "<font color=orange>" + ((hours >24) ? hours -12 :hours); times += ((minutes < 10) ? "<blink>:</blink>0" : "<blink>:</blink>") + minutes+"</font>";
times += (hours >= 12) ? "<b>PM</b>" : "<b>AM</b>";
document.write(times);
// -->
</script>
</b></font>

網站灰黑白色CSS濾鏡代碼 全國哀悼日

根據國務院文件,5.19-5.21為全國哀悼日,在此期間,全國和各駐外機構下半旗志哀,停止公共娛樂活動,外交部和我國駐外使領館設立吊唁簿。5 月19日14時28分起,全國人民默哀3分鐘,屆時汽車、火車、艦船鳴笛,防空警報鳴響。并建議中國所有站 點更換為素裝。國務院決定5月19日至21日為全國哀悼日,為方便站點哀悼,特提供css濾鏡代碼,以表哀悼。以下為全站CSS代碼。

1
html { filter: gray; }

或者

1
html { filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); }

使用方法:這段代碼可以變網頁為黑白,將代碼加到CSS最頂端就可以實現素裝。建議全國站長動起來。為在地震中遇難的同胞哀悼。

  如果網站沒有使用CSS,可以在網頁/模板的HEAD之間插入:

1
2
3
4
<style type="text/css">
<!--
html { filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); }
--></style>

一個網頁鏈接的滑動效果

基于js和css,作者在其首頁提供了DIY的工具。當鼠標經過鏈接的時候,有一個上下滑動的效果。
http://www.scrollovers.com

可以這樣使用這個效果:
1、在網頁中加入如下,可以把js下載下來,放到自己的空間里。

1
<script src="http://www.scrollovers.com/js/scrollovers.js" type="text/javascript"></script>

2、將鏈接形式修改成這樣

1
<a href="http://www.hicode.org/wp-admin/[YOUR PAGE HERE]" TYPE="scrollover" class="scrollover">[YOUR TEXT HERE]</a>

3、添加這樣的CSS,顏色自己修改。

1
2
3
4
<style>
a.scrollover { /* Default Colour/Styles here */ color: #557AFF; }
a.scrollover em:first-line { /* Rollover Colour/Styles here */ color: #FF5B3C; }
</style>

4、還可以修改js,達到你想要的效果。
scrollovers_ScrollSpeed 是控制速度的
scrollovers_ScrollDownOnMouseOver 是控制上滾還是下滾的
scrollovers_TypeName 如果想所有的鏈接都滾動,而不需要設置Type attrbiute的話,把這個變量的值改成空字符

收藏自:Hi,Code!

V2EX所用的CSS圓角代碼

不支持IE瀏覽器,代碼如下:

1
2
-moz-border-radius: 7px;
-webkit-border-radius: 7px;

單獨控制四個角

1
2
3
4
-moz-border-radius-bottomleft:7px;
-moz-border-radius-bottomright:7px;
-moz-border-radius-topleft:7px;
-moz-border-radius-topright:7px;

如何讓IE6-IE7-FF的CSS樣式一致

現在主流的瀏覽器分別是:Internet Explorer 6, Internet Explorer 7和Firefox 2。這讓我們在網站設計中不得不考慮如何使樣式“crossover”。這里介紹一個較為簡單的方法使樣式的顯示效果在上述三種瀏覽器中保持一致。

首先我們針對Firefox 2設計了如下的樣式代碼:

1
#MyDiv { margin : 10px 10px 10px 10px; }

然后針對Internet Explorer 6進行樣式修改,使用如下的代碼語句,該代碼只能被 IE 6 識別:

1
2
/* IE6 Only */
* html #MyDiv { margin : 5px 5px 5px 5px; }

最后針對Internet Explorer 7進行如下樣式修改,該代碼也只能被 IE 7 識別:

1
2
/* IE7 Only */
*:first-child+html #MyDiv { margin : 2px 2px 2px 2px; }

通過上面的方法,你應該能夠讓你的設計樣式更具通用性了。

轉自Smartr.cn