我尝试使用 CSS 在我的网站背景上定位图像。我希望这些图像在我的背景上始终保持相同的位置。但是我的背景图像改变大小并且图像移动...
背景:
html{
background: url("../images/example.gif") no-repeat bottom right fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
图片:
.image{
position: fixed;
right: 219.5px;
top: 368px;
}
有什么办法可以让图像始终保持相同的位置吗?
最佳答案
请试试这个:
html{
background: url("../images/bg.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
color:#fff;
background-color:#FFF;
position: relative;
}
CSS:
.image{
position: fixed;
right: 219.5px;
top: 368px;
}
关于html - 在背景上定位图像(背景大小变化),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32410992/