1、background-attachment特性
在CSS中,应用情况附件特性background-attachment能够设定情况图象是随目标翻转還是固定不动没动。
英语的语法:
background-attachment:scroll/fixed;
表明:
background-attachment 特性仅有2个特性值。scroll表明情况图象随目标翻转而翻转,是默认设置选项;fixed表明情况图象固定不动在网页页面没动,仅有别的的內容随翻转条翻转。
举例:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> #div1 { width:160px; height:1200px; border:1px solid gray; background-image:url("cartoongirl.gif"); background-repeat:no-repeat; background-attachment:fixed; } </style> </head> <body> <div id="div1"></div> </body> </html>
在访问器预览实际效果以下:
剖析:
大伙儿在访问器中拖拽右侧的翻转条会发现,情况照片在网页页面固定不动没动。
在IE或360中设定background-attachment以后不可以设定background-position特性,要不然照片没法在访问器显示信息。大伙儿能够检测1下google访问器、Firefox访问器。