首页 > 解决方案 > IONIC4背景图像在键盘打开时调整大小

问题描述

我正在尝试为我的登录页面设置背景图片,一些基本的东西。但是,当按下其中一个输入并显示键盘时,图像会被调整大小(小尺寸)

我的背景图像位于 div 标签中,我尝试将图像放在 ion-content 标签中,它解决了键盘问题,但随后图像放大了太多。我尝试使用 ion-view 标签,但随后出现以下错误

....错误:模板解析错误:'ion-view' 不是已知元素:

这是我的 html 代码(虽然是一些基本的东西)

<div class="bg">
<form #form="ngForm" (ngSubmit)="login(form)">

</form>

<ion-label ... ></ion-label> 
</div>

这是我的 bg 课程:

.bg{
padding-bottom: 0 !important;
background-image: url('../../assets/lock.png') !important;
height: 100% !important;
width: 100% !important;
background-repeat: no-repeat;
background-image: cover !important;
background-size: cover !important;
background-position: center; 
background-attachment: fixed;}

标签: ionic-frameworkionic4

解决方案


尝试这个

ion-content { 
  background: url(images/bg.jpg) no-repeat center center fixed; 
  background-size: cover;
} 

推荐阅读