Why is background-size:cover
不同如果background-attachment: scroll
or background-attachment: fixed
used?
Example:
http://jsfiddle.net/enriqg9/Yn43U/ http://jsfiddle.net/enriqg9/Yn43U/
区别并不在于background-size: cover
。和...之间的不同background-attachment: scroll
and background-attachment: fixed
is that
"...scroll意味着背景相对于元素本身是固定的,并且不会随其内容滚动。 (它有效地附加到元素的边框。)
"...fixed意味着背景相对于视口是固定的。即使元素具有滚动机制,“固定”背景也不会随元素移动。”
as MDN https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment说。所以你会在你的小提琴中看到background-attachment: fixed
背景不会保留在其包含元素中<div id="two">
边界。而是在整个身体的背景中采取绝对定位0、0的固定点。
在本质上,background-attachment: fixed
正在覆盖background-size: cover
并且不允许后一种样式生效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)