网页背景图片固定代码[转]

在网上看到的,很好用,转载一下:

注:使用時,请把代码中的/images/bg.jpg换为您的背景图片实际网址

固定在右上角:

<style type="text/css">
<!--
body{
background-image:url(/images/bg.jpg);
background-position:100% 0%;
background-repeat:no-repeat;
background-attachment:fixed;}
-->
</style>

固定在右下角:

<style type="text/css">
<!--
body {
background-color: #FFFFFF;
background-image: url(/images/bg.jpg);
background-repeat: no-repeat;
background-attachment: right bottom;
}
-->
</style>

固定在左上角:

<style type="text/css">
<!--
body{
background-image:url(/images/bg.jpg);
background-repeat:no-repeat;
background-attachment:fixed;} 
-->
</style>

固定在左下角:

<style type="text/css">
<!--
body{
background-image:url(/images/bg.jpg);
background-position:0% 100%;
background-repeat:no-repeat;
background-attachment:fixed;}
-->
</style>

固定在正中央:

<style type="text/css">
<!--
body{
background-image:url(/images/bg.jpg);
background-repeat:no-repeat;
background-attachment:fixed;
background-position:center ;} 
-->
</style>

固定在右边:

<style type="text/css">
<!--
body{
background-image:url(/images/bg.jpg);
background-position:100% 0%;
background-repeat:repeat-y;
background-attachment:fixed;}
-->
</style>

固定在左边:

<style type="text/css">
<!--
body{
background-image:url(/images/bg.jpg);
background-repeat:repeat-y;
background-attachment:fixed;}
-->
</style>

固定在上面:

<style type="text/css">
<!--
body{
background-image:url(/images/bg.jpg);
background-repeat:repeat-x;
background-attachment:fixed;}
-->
</style>

固定在下面:

<style type="text/css">
<!--
body{
background-image:URL(/images/bg.jpg);
background-position:bottom;
background-repeat:repeat-x;
background-attachment:fixed;}
-->
</style>

《网页背景图片固定代码[转]》上有7条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.