我正在建立一个网站,但我想将图片放在背景中,但我无法将其放在我想要的位置。
我希望网页上图像的“焦点”位于图像中心几像素处。宽度我都能看出来,但是高度没有。
图像分辨率为“5760x3840px”。
所以,我有一段用于图像设置的 css 代码。
.topwidget{
max-width: 100%;
height: auto;
background-image: url(../images/welcome_banner_bg.jpg);
background-repeat: no-repeat;
background-size: 100%;
background-position: bottom 1000px;
margin-bottom: 20px;
padding: 50px 0;
}
最佳答案
Try this
.topwidget{
max-width: 100%;
height: auto;
background-image: url(../images/welcome_banner_bg.jpg);
background-repeat: no-repeat;
background-size: 100%;
**background-position: center 10px;**
margin-bottom: 20px;
padding: 50px 0;
}
关于CSS 图像位置/焦点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41484388/