CSS“背景位置:中心”不适用于移动设备

问题描述

我目前正在一个网站页面上,其中一张图像覆盖了整个页面。这是我的代码。

- (void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer {
    
    
    CGPoint p = [gestureRecognizer locationInView:self.tableView];
    selectedIndexPath = [self.tableView indexPathForRowAtPoint:p];
    

    if (selectedIndexPath != nil && gestureRecognizer.state == UIGestureRecognizerStateBegan) {
        [self.tableView reloadData];
        [self resetTableView];
        
        PresentationCell *cell = (PresentationCell *)[self.tableView cellForRowAtIndexPath:selectedIndexPath];
        NSLog(@"start click");
        [cell.deleteButton setHidden:NO];
        [cell.updateShowView setHidden:YES];
        if (IS_IPAD) {
                [cell.nameLabel setHidden:NO];
                [cell.descriptionLabel setHidden:NO];
        } else {
                [cell.nameLabel setHidden:YES];
                [cell.descriptionLabel setHidden:YES];
        };
        
        // Use ivar
        if ( ! self.pressed ) {
            self.pressed = YES; // Never fire again
            hideButtonTimer = [NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(hideButton) userInfo:nil repeats:NO];
        }
        // Reset timer if it is counting down
        else if ( hideButtonTimer ) {
           // Invalidate old timer
           [hideButtonTimer invalidate];
           // Start a new one
           hideButtonTimer = [NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(hideButton) userInfo:nil repeats:NO];
        }
        // else timer already fired - no action
        
        //NSLog(@"%@",hideButtonTimer);
    }
}
.cover-bg {
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
}

.banner { /* linear-gradient darkens out the background image */
  background-image: linear-gradient(rgba(0,0.5),rgba(0,0.5)),url("../images/image.jpg");
  background-attachment: fixed;
  height: 100vh;
  width: 100%;
}

这在PC和Mac上运行良好,即使缩小浏览器大小,效果也很好。但是,它仅在移动设备上不起作用(图像未居中,因此图像看起来非常难看)。我已经在网上进行了数小时的研究,并尝试了其他人为解决此问题而采取的所有可能的解决方案,但对我来说没有任何用处。你们中有没有人知道如何解决这个问题?

在移动设备上,我同时尝试了Safari和Chrome浏览器(两者均无法正常运行),并且我认为Firefox也无法正常运行。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...