我需要将我的背景图像放在屏幕的正中心,但是我现有的代码使得图像在顶部被截断。这是我到目前为止的代码:
body {
background-image: url(img/tooslow.gif);
background-repeat: no-repeat;
background-position: center;
min-width: 100%;
min-height: 100%;
}
img {
position: absolute;
bottom: 15%;
left: 42.5%;
margin: auto;
width: 250px;
height: 250px;
<a href="tooslow2.html"><img src="img/too1.png"></a>
答案 0 :(得分:0)
尝试以下更新的代码段。
body {
background-image: url(img/tooslow.gif);
background-repeat: no-repeat;
background-position: center;
min-width: 100%;
min-height: 100%;
}
img {
position: absolute;
top: 50%;
left: 50%;
margin-top: -125px;
margin-left: -125px;
width: 250px;
height: 250px;
}
<a href="tooslow2.html"><img src="img/too1.png"></a>
答案 1 :(得分:0)
body {
background-image: url(http://www.jqueryscript.net/images/Simplest-Responsive-jQuery-Image-Lightbox-Plugin-simple-lightbox.jpg);
background-repeat: no-repeat;
background-position: center;
min-width: 100%;
min-height: 100%;
}
img {
position: relative;
bottom: 15%;
left: 42.5%;
margin: auto;
width: 250px;
height: 250px;
}
&#13;
<a href="http://www.jqueryscript.net/images/Simplest-Responsive-jQuery-Image-Lightbox-Plugin-simple-lightbox.jpg"><img src="http://www.jqueryscript.net/images/Simplest-Responsive-jQuery-Image-Lightbox-Plugin-simple-lightbox.jpg"></a>
&#13;
将您的图像位置更改为相对
答案 2 :(得分:0)
将以下代码添加到img
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void) {
[self addAllImages];
dispatch_sync(dispatch_get_main_queue(), ^(void) {
[self pageControlSetUp];
self.fullScreenImageView.hidden = YES;
});
});