css设置背景固定不滚动效果的示例
发布时间:2017-12-13 编辑:jiaochengji.com
教程集为您提供css设置背景固定不滚动效果的示例等资源,欢迎您收藏本站,我们将为您提供最新的css设置背景固定不滚动效果的示例资源
背景固定不滚动各位看到最多的无非就是QQ空间了,我们在很多的空间都可以看到内容滚动而北京图片不滚动了,下文整理了几个关于背景固定不滚动css代码。
一、css设置背景不滚动的效果
<pre class="brush:css;toolbar:false"><!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>css禁止背景滚动 - www.jbxue.com<jquerycn.cntyle type="text/css"> *{ margin:0; padding:0;} html,body{ width:100%; height:100%; overflow:auto; position:relative;} .container{ width:100%; height:100%; overflow:auto;} .bg{ background:#000000;opacity:0.5; filter:alpha(opacity=50); position:absolute; z-index:1; overflow:auto; width:100%; height:100%; left:0; top:0;} .box{ position:absolute; left:50%; top:50%; width:300px; z-index:11; height:300px; line-height:300px; color:#f60; font-weight:bold; font-size:20px;} .info{ position:absolute; left:-50%; top:-50%; z-index:10; width:300px; height:300px; text-align:center; border:1px solid #f00; background:#fff;} </style> </head> <body> <div class="container"> <script type="text/javascript"> for(var i=0;i<150;i ){ document.write('<center>脚本学堂,div css教程,禁止背景图片滚动。</center>'); } </script> </div> <div class="bg"></div> <div class="box"><div class="info">我就不动</div></div> </body> </html></pre>二、css设置body背景图片固定不动内容滚动
css中使body背景图片固定不动内容滚动:
style="background-attachment: fixed"
例子:
三、css固定背景图片不滚动
例子:
四、css设置页面背景不动只滚动条动效果
方法一(页面背景不动只滚动条动):
方法二(页面背景不动只滚动条动):
从上面的几个例子来看背景不滚动都是通过定位来解决了,上面的例子各有千秋了各位可以选择合适自己的效果代码。
您可能感兴趣的文章:
[关闭]