css背景

发布于:2022-12-14 ⋅ 阅读:(397) ⋅ 点赞:(0)

目录

背景图片 :

 背景图片位置:

背景图像固定:

背景平铺:

联写约定:


背景图片 :

        便于控制位置

        background-image :none | url(url) ;

div{
			background-image: url("file:///H:/html/html%20file/picture/news.jpg")
		}

 背景图片位置:

        background-position:x y;

        以左上方为起点右下为正方向,水平 x 垂直 y  ,左边是 x 右边是 y 中间用空格隔开,只设置一个值时,默认为 x 而且垂直居中。

        x 和 y 可以由准确数值或方位名词组成。

length :百分数或由浮点数字和单位标识符组成的长度值 。

position :top 、center 、bottom 、left 、center、right。

方位名词 center right 等同于 right center。

背景图像固定:

                

        背景图像是否固定或随着页面其他部分滚动。

background-attachment :scroll;(默认,滚动)

background-attachment :fixed;        (固定)

背景平铺:

        图像太小时可能会水平垂直重复,使用 background-repeat 设置。

background-repeat :repeat(平铺)、no-repeat(不平铺)、repeat-x(水平平铺)、repeat-y(垂直平铺);

联写约定:

background :颜色、图片地址、平铺、滚动、位置;

background :color  url  repeat  fixed  right  center;

背景色透明:

opcity : 0.3;

background :rgba( 0 ,  0 , 0 , 0.3);