欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

css 背景固定

shiping1 的头像

css背景固定 background-attachment:fixed;

 

使用CSS可以固定背景,格式如下:
标签名{background-attachment:参数}

参数:
fixed:页面滚动时,背景固定;
scroll:页面滚动时,背景滚动。

实例:

<html>
<style type="text/css">
<!--
    p.1{ background-attachment:fixed;  background-repeat:no-repeat;background-image:url(mgc.jpg);font-size:100mm}
    p.2{ background-attachment:scroll;  background-repeat:no-repeat;background-image:url(mgc.jpg);font-size:100mm}
-->
</style>
<head>
    <title>CSS</title>
</head>
<body>

    <p class="1">fixed</p>
    <p class="2">scroll</p>
    
</body>
</html>

普通分类: