css中背景相关的属性有哪些

这篇文章主要介绍css中背景相关的属性有哪些,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

创新互联专注于宜州企业网站建设,响应式网站设计,购物商城网站建设。宜州网站建设公司,为宜州等地区提供建站服务。全流程定制设计,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务

css背景有哪些相关属性

1、css背景属性之为内容设置背景色:background-color;
属性:
颜色;
 inherit;继承父级样式

box.html

<!doctype html>
<html>
<head>
    <mate charset="utf-8">
    <title>背景</title>
    <link href="box.css" type="text/css" rel="stylesheet">
    </head>
    <body>
    <p为内容设置背景色:background-color;</p>
    </body>
    </html>

box.css

body{    
background-color:#123456;
}

2、css背景属性之为内容设置背景为图片background-image:url();
box.css

body{
    background-color:#123456;    
    background-image:url(image.png);
    }

3、css背景属性之固定背景图片background-attachment
(在CSS中使用 background-attachment属性可以将图片固定在浏览器上,如果拖动滚动条,背景图片不会随着网页内容的滚动而滚动,像文字浮在图片上)
属性值:
scroll;背景图片随内容滚动,默认值
fixed; 背景图片固定,不随内容滚动
inherit;继承父类样式

box.css

body{
    background-color:#123456;    
    background-image:url(image.png);    
    background-attachment:fixed;    
    font-size: 45px;
    }

4、css背景属性之背景图片平铺background-repeat;
属性值:
  repeat;平铺背景图片;默认
  no-repeat;不平铺图片;
  repeat-x;在水平方向平铺
  repert-y;在竖直方向平铺

box.css

 body{
     background-color:#123456;    
     background-image:url(image.png);    
     background-attachment:fixed;    
     font-size: 45px;    
     background-repeat: repeat-y;    
}

5、css背景属性之背景图片定位background-position
属性值:
top;顶部
center;中间
bottom;底部
right;右边
left;左边
inherit;继承父类样式
样式:
  xxxpx,xxxpx;
  xxx%,xxx%;
  xxxpx,top;

box.css

body{
    background-color:#123456;    
    background-image:url(image.png);    
    background-attachment:fixed;    
    font-size: 45px;    
    background-repeat:no-repeat;    
    background-position:left;
    }

以上是“css中背景相关的属性有哪些”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!

当前名称:css中背景相关的属性有哪些
链接URL:https://www.cdcxhl.com/article42/goipec.html

成都网站建设公司_创新互联,为您提供电子商务搜索引擎优化全网营销推广云服务器品牌网站制作

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都app开发公司