常用CSS語句

來源:互聯網
上載者:User
控制橫向和縱向捲軸的顯隱?
<body style="overflow-y:hidden"> 去掉x軸
<body style="overflow-x:hidden"> 去掉y軸
<body scroll="no">不顯
表格變色
<TD onmouseover="this.style.backgroundColor='#FFFFFF'"
onmouseout="this.style.backgroundColor=''"
style="CURSOR: hand">

禁止複製,滑鼠拖動選取
<body ondragstart=window.event.returnValue=false oncontextmenu=window.event.returnValue=false onselectstart=event.returnValue=false>

普通iframe頁面
<iframe name="name" src="main.htm" width="450" height="287" scrolling="Auto" frameborder="0"></iframe>
iframe自適應高度
<iframe name="pindex" src="index.asp" frameborder=false scrolling="auto" width="100%" height="100%" frameborder=no onload="document.all['pindex'].style.height=pindex.document.body.scrollHeight" ></iframe>

IE地址欄前換成自己的表徵圖&可以在收藏夾中顯示出你的表徵圖
<link rel="Shortcut Icon" href="favicon.ico">
<link rel="Bookmark" href="favicon.ico">

字型大小縮放
越來越多的人長時間的泡網,眼鏡的普及率也越來越高,讓文字大點,讓更多的使用者看的更清楚。
<script type="text/javascript">
function doZoom(size)
{document.getElementById('zoom').style.fontSize=size+'px';}
</script>
<span id="zoom">需要指定大小的文字</span>
<a href="javascript:doZoom(16)">大</a> <a href="javascript:doZoom(14)">中</a> <a href="javascript:doZoom(12)">小</a>

select擋住div的解決方案
在div裡加入下面的代碼,根據需要調整就可以了。
<iframe src="javascript:false" scrolling="no" frameborder="0" style="z-index:-1;position:absolute; top:5px; left:2px;width:168;height:100px;">
</iframe>
iframe(嵌入式幀)自適應高度
填寫的嵌入地址一定要和本頁面在同一個網站上,否則會提示“拒絕訪問!”。對跨域引用有許可權問題,請查閱其他資料。
<iframe name="guestbook" src="gbook/index.asp" scrolling=no width="100%" height="100%" frameborder=no onload="document.all['guestbook'].style.height=guestbook.document.body.scrollHeight"></iframe>

導向功能表新視窗
<select name="select" onchange="window.open(this.options[this.selectedIndex].value)">
<option value="http://www.microsoft.com/ie"> Internet Explorer</option>
<option value="http://www.microsoft.com"> Microsoft Home</option>
<option value="http://msdn.microsoft.com"> Developer Network</option>
</select>

flash透明選項
<param name="wmode" value="transparent">

添加到收藏夾和設為首頁
添加到收藏夾:
<a href="javascript:window.external.addFavorite('http://連結','說明');">添加到收藏夾</a>
設為首頁:
<a href=# onclick=this.style.behavior='url(#default#homepage)';this.setHomePage ('http://連結');>設為首頁</a>

記錄並顯示網頁的最後修改時間
<script language=JavaScript>
document.write("最後更新時間: " + document.lastModified + "")
</script>

節日倒計時
<Script Language="JavaScript">
   var timedate= new Date("October 1,2002");
   var times= "國慶節";
   var now = new Date();
   var date = timedate.getTime() - now.getTime();
   var time = Math.floor(date / (1000 * 60 * 60 * 24));
   if (time >= 0)
   document.write( "現在離"+times+"還有: "+time +"天")
</Script>

加在HEAD裡
禁止緩衝
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
讓IFRAME架構內的文檔的背景透明
<iframe src="about:<body style='background:transparent'>" allowtransparency></iframe>

開啟視窗即最大化
<script language="JavaScript">
<!-- Begin
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
// End -->
</script>

加入背景音樂
<bgsound src="mid/windblue[1].mid" loop="-1"> 只適用於IE
<embed src="music.mid" autostart="true" loop="true" hidden="true"> 對Netscape ,IE 都適用

滾動
<marquee direction=up height=146 onmouseout=start() onmouseover=stop() scrollAmount=2>滾動資訊
</marquee>

防止點擊空連結時,頁面往往重設到頁首端
代碼“javascript:void(null)”代替原來的“#”標記

文字或圖片彈出指定大小的視窗
在body中加入
<script language="JavaScript" type="text/JavaScript">
function MM_openBrWindow(theURL,winName,features) {window.open(theURL,winName,features);}
</script>
彈出代碼
<a href="#" target="_self" onClick="MM_openBrWindow('windows01.htm','','width=550,height=380')" width="550" height="380" border="0">圖片或文字</a>

flash按鈕加連結
on (press) {
getURL("http://www.makewing.com","_blank");
}

跳轉頁面代碼
<meta http-equiv="refresh" content="5;url=http://www.makewing.com">

細線分隔線
<hr noshade size=0 color=#C0C0C0>

網頁中的自動換行
<td style="word-break:break-all">就搞定了。
完整的是
style="table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word"

消除ie6自動出現的映像工具列,設定 GALLERYIMG屬性為false或no .
<IMG src="mypicture.jpg" HEIGHT="100px" WIDTH="100px" GALLERYIMG="no">

禁止頁面本文內容被選取
<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return
false"onmouseup="document.selection.empty()">
不能點右鍵,不用CTRL+A,不能複製作!
<body oncontextmenu="window.event.returnValue=false"
onkeypress="window.event.returnValue=false"
onkeydown="window.event.returnValue=false"
onkeyup="window.event.returnValue=false"
ondragstart="window.event.returnValue=false"
onselectstart="event.returnValue=false">
</body>

IE瀏覽器支援一個 Body 屬性 bgproperties,它可以讓背景不滾動:
<Body Background="圖片檔案" bgproperties="fixed">

隨機變換背景圖象(一個可以重新整理心情的特效)
<Script Language="JavaScript">
   image = new Array(4); //定義image為圖片數量的數組
   image [0] = 'tu0.gif' //背景圖象的路徑
   image [1] = 'tu1.gif'
   image [2] = 'tu2.gif'
   image [3] = 'tu3.gif'
   image [4] = 'tu4.gif'
   number = Math.floor(Math.random() * image.length);
   document.write("<BODY BACKGROUND="+image[number]+">");
</Script>
flash載入影片
on (release)
{
loadMovie("1-01.swf", "_root.loaderclip");
}

圖片表單按鈕
<form id="form1" name="form1" method="post" action="">
<img src="login.gif" width="62" height="22" onclick="document.form1.submit()" />
</form>

左右陰影背景的CSS定義方法
body {
text-align:center;
background-repeat: repeat-y;
background-position: center;
background-image: url(../images/bg.jpg);
}
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.