首页编程background-attachment?在css中background-attachment: fixed的意思是啥

background-attachment?在css中background-attachment: fixed的意思是啥

编程之家2023-11-02101次浏览

亲爱的读者们,你是否对background-attachment和在css中background-attachment: fixed的意思是啥的关系感到好奇?在本文中,我将深入探讨它们之间的联系,让你对此有更深刻的理解。

background-attachment?在css中background-attachment: fixed的意思是啥

在css中background-attachment: fixed的意思是啥

在CSS中,首先需要理解background-attachment的意思是定义背景图片随滚动轴的移动方式,取值方式有:scroll| fixed| inherit,scroll:随着页面的滚动轴背景图片将移动,fixed:随着页面的滚动轴背景图片不会移动,inherit:继承,具体的用法通过代码来理解:

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>

<title>CSS background-attachment属性示例</title>

background-attachment?在css中background-attachment: fixed的意思是啥

<style type="text/css" media="all">

body

{

background-image:url('/images/list-orange.png');//图片的地址你可以去自行添加,这里只是假设的一种图片

background-attachment:fixed;

background-repeat:repeat-x;

background-attachment?在css中background-attachment: fixed的意思是啥

background-position:center center;

position:absolute;

height:5000px;

}

</style>

</head>

<body>

<p>拖动滚动条,并且注意中间有一条橙色线并不会随滚动条的下移而上移.</p>

在DW软件中background是什么意思

background简写属性在一个声明中设置所有的背景属性。

可以设置如下属性:

background-color

background-position

background-size

background-repeat

background-origin

background-clip

background-attachment

background-image

如果不设置其中的某个值,也不会出问题,比如 background:#ff0000 url('smiley.gif');也是允许的。

通常建议使用这个属性,而不是分别使用单个属性,因为这个属性在较老的浏览器中能够得到更好的支持,而且需要键入的字母也更少。

默认值:not specified

继承性:no

版本:CSS1+ CSS3

JavaScript语法:object.style.background="white url(paper.gif) repeat-y"

实例

如何在一个声明中设置所有背景属性:

body

{

background:#00FF00 url(bgimage.gif) no-repeat fixed top;

}

background-image:url()用法

background-image:url()用法如下:

background-image为元素设置背景图像,占据了元素的全部尺寸。

1、示例:

.div{。

background-image:url(xxx.jpg);}。

background-image是指在元素背景中设置一个图像。

url是指图像的地址位置。

xxx.jpg是指图片名称以及前面需要添加图片路径。

2、background-image默认以左上角垂直的水平方向重复。

url可以使用绝对路径也可以使用相对路径。

3、默认值:none;不显示默认图像。

继承;no。

css3中属性值可以是多值模式,多个用英文逗号分隔。

示例:

background-image。

url(aaa.jpg)。

url(bbb.jpg)。

4、background-position属性设置图像的起始位置。

background-repeat定义图像的平铺模式。

background-attachment定义图像固定或者是页面滚动。

5、javascript使用:object.style.backgroundImage="url(xxx.jpg)"。

CSS--background系列属性

css2.1中,颜色的表示方法有三种:(1)单词;(2)rgb表示法(十进制表示法);(3)十六进制表示法。

能够用英语单词来表述的颜色,都是简单颜色。

红色:background-color: red;

红色:background-color:rgb(255,0,0);

rgb(red、green、blue)表示三原色“红”“绿”“蓝”。光学显示器,每个像素都是由三原色的发光原件组成的,靠明亮度不同调成不同的颜色。

用逗号隔开r,g,b的值,每个值的取值范围是0~255,一共256个值。

如果此项的值是255,那么就说明是纯色:

绿色:background-color:rgb(0,255,0)

蓝色:background-color:rgb(0,0,255)

黑色:background-color:rgb(0,0,0)

白色:background-color:rgb(255,255,255)

颜色可以叠加,比如黄色就是红色和黄色的叠加:

黄色:background-color:rgb(255,255,0)

紫色:background-color:rgb(255,0,255)

青色:background-color:rgb(0,255,255)

红色:background-color:#ff0000;

所有用#开头的值,都是16进制的。

#ff0000(ff表示r,00表示g,00表示b)

16进制表示法和rgb类似,也是两位两位的看,但是没有逗号隔开。

上述红色表示法中:ff就是10进制的255,00就是十进制的0,所以#ff0000相当于(255,0,0)

十六进制对照表:

任何一种十六进制表示法都能够换算成rgb表示法。也就是说,两个表示法能表示的颜色数量一样多,十六进制能够简化成3位,所有#rrggbb的形式,都可以写成#rgb;

比如,上述的红色可以写成background-color:#f00;

但是,如果要采用简化的方法,必须满足rrggbb格式才行。

几个特殊的要记住:

黑:#000

白:#fff

红:#f00

灰:#333

深灰:#222

浅灰:#ccc

background-image属性用于给盒子加上背景图片:

background-image:url(images/1.jpg)

url()表示网址。、

images/1.jpg就是相对路径。

背景会默认循环,平铺满整个盒子,padding的区域也会有背景图。

background-repeat属性用来设置背景图是否重复以及重复方式。

“repeat”表示“重复”。

默认为铺满,不用设置。

不重复:background-repeat:no-repeat;

横向重复:background-repeat:repeat-x;

纵向重复:background-repeat:repeat-y;

background-position:背景定位属性。

格式:background-position:向右移动量(100px)向下移动量(200px)

向上向左移只需把移动量改成负数即可。

css精灵又叫“css雪碧”技术,是一种css图像拼合技术,该方法是将小图标和图像合并到一张图上,然后利用css背景定位来显示需要显示的图片部分。

css精灵的优点,就是减少了http请求。比如4张小图片,原本需要4个http请求。但是用了css精灵,小图片变为了一张图,http请求只有1个了。

background-position:描述左右的词描述上下的词;

比如:background-position:right bottom:(右下角)

background-position:center center;(居中)

背景固定属性。

格式:background-attachment:fixed;

背景就会被固定住,不会被滚动条滚走。

background属性和border一样,是一个综合属性:

background:red url(1.jpg) no-repeat 100px 100px fixed;

等价于:

background-color:red;

background-image:url(1.jpg);

background-repeat:no-repeat;

background-position:100px 100px;

background-attachment:fixed;

可以任意省略部分:

background:red;

关于background-attachment的内容到此结束,希望对大家有所帮助。

我想做网站 我想做个网站,该怎么做佛山小程序开发?佛山做一个小程序开发大概要多少钱