最近在慢慢学CSS
网页背景设置方法
背景设置颜色:
<style>
body {
background-color: #F0F8FF
}
</style>
背景设置图片:
<style type="text/css">
body{
background: url("./photoes/background.jpg") no-repeat center center fixed;
/*兼容浏览器版本*/
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;
} /*背景图*/
.test {
margin-top: 100px;
}
</style>
注意:CSS 有三种方式添加到HTML中:
1、内联样式- 在HTML元素中使用"style" 属性
2、内部样式表 -在HTML文档头部 <head> 区域使用<style> 元素 来包含CSS
3、外部引用 - 使用外部 CSS 文件
在设置背景图这里我用的是加到<head>里面