background-attachement属性主如果定义背景图象是不是随内容转动或者是坚持牢固
它的属性值为
fixed:示意背景图象在浏览器窗口中坚持牢固,并且在转动元素或页面时不挪动。
scroll:示意当文档转动时,背景图象与对象一同转动
鄙人面的案例中运用background-attachment属性中的“fixed”,使背景不会随文本转动而转动
body{ background-image: url("images/7.jpg"); background-attachment:fixed; background-repeat: no-repeat; }
效果图:
将fixed换成scroll,背景图将会跟着文本的转动而转动
body{ background-image: url("images/7.jpg"); background-attachment:scroll; background-repeat: no-repeat; }
效果图:
总结:所以我们能够将background-attachement属性设置为fixed来让图片牢固不动。
以上就是怎样设置背景图片不跟着文本内容的转动而转动的细致内容,更多请关注ki4网别的相干文章!