» 网友学堂 » HTML/CSS教程 » 固定背景特效代码
固定背景特效代码
作者:问天 发表时间:2006-8-26 21:03 阅读:1634次 在百度搜索相关内容

<STYLE type="text/css">
body {background-image:url("hana1.jpg");//修改图片地址为自己的。
background-position:bottom right;//修改这儿的top,bottom,right,left,就可以将图片背景固定在你喜欢的上下左右的位置上,本页例子是固定在右下角的图片。
background-repeat:no-repeat;}
H1 {color:#00;}
</STYLE>



//以上代码加在<head>...</head>之间


图片背景固定为左侧一列固定

<STYLE type="text/css">
<!--
BODY{
background-image:url(图片地址);
background-repeat : repeat-y;
background-attachment : fixed;
background-position : left top;
}
-->
</STYLE>


//以上代码加在<head>...</head>之间



图片背景固定为上方一排出现

<STYLE type="text/css">
<!--
BODY{
 background-image:url(图片地址);
background-repeat : repeat-x;
background-attachment : fixed;
}
-->
</STYLE>


//以上代码加在<head>...</head>之间



图片背景固定在任意

<STYLE type="text/css"><!--
BODY {
background-image : url("图片地址");
background-attachment: fixed;
background-position:50% 80%;//修改这儿的百分比,就可以将图片做为背景固定在任何想放的位置。
background-repeat: no-repeat;}
-->
</STYLE>


//以上代码加在<head>...</head>之间



背景特效--背景颜色的多色变幻

<META http-equiv=Content-Type content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<!--JavaScript-->
<SCRIPT Language="JavaScript">
<!--

function tmycchange(){
tmyc1=Math.round(255*Math.random());
tmyc2=Math.round(255*Math.random());
tmyc3=Math.round(255*Math.random());
tmycol1=tmyc1.toString(16);
tmycol2=tmyc2.toString(16);
tmycol3=tmyc3.toString(16);
tmycol4=tmycol1+tmycol2+tmycol3;
tmycol5=eval("tmycol4");
document.bgColor="#"+tmycol5;
}
function tmycchangOrijin(){
document.bgColor="#"+"eeeeff";
}


// -->
</SCRIPT>

</HEAD>
<BODY bgcolor="#eeeeff" TEXT="#000080" link="#000080" vlink="#000080">
<br><br><br>

<center>

<a href="#" onMouseover="tmycchange()" onMouseout="tmycchangOrijin()">将标鼠放上来看看效果</a>
<br><br><br><br><br><br>

<SCRIPT LANGUAGE="JavaScript">
<!--
function viewSource(){
location = "view-source:" + window.location;
}
//-->
</SCRIPT>
<FORM>
<INPUT TYPE="button" VALUE="查看源代码" onClick="viewSource()">
</FORM>
</center>

</body>

#Advertisement
#1 baissy 发表评论于:2006-11-30 21:28
搞不懂哦~