这对我来说是相当愚蠢的,但如何在页面滚动期间保持背景图像的固定。我有这个css代码,图像是正文的背景而不是<div></div>
body{
background-position:center;
background-image:url(../images/images5.jpg);
}
由于 让
答案 0 :(得分:104)
background-attachment: fixed;
http://www.w3.org/TR/CSS21/colors.html#background-properties
答案 1 :(得分:5)
background-image: url("/your-dir/your_image.jpg");
min-height: 100%;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size: cover;}
答案 2 :(得分:2)
只需在代码中添加背景附件
即可body {
background-position: center;
background-image: url(../images/images5.jpg);
background-attachment: fixed;
}