您现在的位置:科汛网络开发 >> 站长充电站 >> div+css >> 浏览文章

4、div+css:定义背景
来源:互联网 作者:未知 更新时间: 2009年09月19日 点击:

@charset"gb2312";
body { background-color:"#999999" }
p {
font-family: "宋体";
font-size:30px;
color:"#FF0000";
}
-->
</style>
</head>
<body>
使用background-color设置了body的背景色
<p>
千山鸟飞绝万径人踪灭
</p>
<p> </p>
</body>
</html>

2.背景图案:background-image

语法:{background-image: url(URL)}

说明: URL就是背景图片的存放路径。

示例 s3-2.htm


3.图案重复:background-repeat

语法:{background-repeat:inherit|no-repeat|repeat|repeat-x|repeat-y}

参数取值范围:

·inherit 继承
·no-repeat 不重复平铺背景图片
·repeat 使图片完全平铺,为默认值
·repeat-x 使图片只在水平方向上平铺
·repeat-y 使图片只在垂直方向上平铺

示例 s3-3.htm


4.图案滚动:background-attachment

语法:{background-attachment:fixed|scroll}

参数:

·scroll 页面滚动时背景也滚动
·fixed:页面滚动时背景不滚动

示例 s3-4.htm


5.图案定位:background-position

语法:{background-position:数值|top|bottom|left|right|center}

参数:

·top:顶对齐 background-position:top;
·bottom:底对齐 background-position:bottom;
·left:左对齐
·right:右对齐
·center:中心对齐
·绝对数值:background-position:200pt 100pt;
·相对比例:background-position:20% 70%;

示例 s3-5.htm


示例 s3-6.htm


设为首页 | 加为收藏 | 关于我们 | 服务条款 | 广告服务 | 免责声明