Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 随着安卓设备上出现软键,我的网站在安卓系统中的背景图像越来越小_Android_Css_Html - Fatal编程技术网

Android 随着安卓设备上出现软键,我的网站在安卓系统中的背景图像越来越小

Android 随着安卓设备上出现软键,我的网站在安卓系统中的背景图像越来越小,android,css,html,Android,Css,Html,我已经创建了一个响应网页使用html和CSS。 我将背景图像设置如下: body { background: url('mobile.jpg') no-repeat center center fixed; background-size: 100% 100%; } 当我在android设备上测试它时,它在屏幕上看起来非常完美,但只要我点击输入框,屏幕上就会出现软键盘,这使得我的背景图像重新调整大小 如何避免图像在软键外观上重新调整大小?背景图像正在调整大小,因为主体实际上正在

我已经创建了一个响应网页使用html和CSS。 我将背景图像设置如下:

body
{
    background: url('mobile.jpg') no-repeat center center fixed;
    background-size: 100% 100%;
}
当我在android设备上测试它时,它在屏幕上看起来非常完美,但只要我点击输入框,屏幕上就会出现软键盘,这使得我的背景图像重新调整大小


如何避免图像在软键外观上重新调整大小?

背景图像正在调整大小,因为
主体实际上正在调整大小。当键盘打开时,页面尺寸会相应调整大小,以便您可以在键盘下滚动而不隐藏任何内容。有些安卓键盘的模式是,它们在屏幕上漂浮在内容上,而不是在输入下排列,但这是网页设计师无法控制的


你必须使用背景大小以外的东西:100%100%。例如,如果使用
背景大小:100%使用百分比时,宽度和高度根据父div(可以是主体或顶部父div)调整大小

替换
背景尺寸:100%100%背景尺寸:封面会起作用的

这是我的解决方案:

    var isTouch = window.matchMedia("only screen and (hover: none) and (pointer: coarse)");
    if (isTouch.matches) {

        function getHeight() {
            return screen.height;
        }

        function getWidth() {
            return screen.width;
        }

        var oldWidth =  getWidth();
        var oldHeight = getHeight();

        function setBodyStyleWidthAndHieght() {

            try {
                if (oldWidth === getHeight() && oldHeight === getWidth()) {
                    //The device has been flipped;
                    let temp = oldWidth;
                    oldWidth = oldHeight;
                    oldHeight = temp;   
                }

                document.body.setAttribute("style",oldWidth<oldHeight ? "background-size: auto " + oldHeight + "px;" : "background-size:"+oldWidth+"px auto;");     
            } catch (error) {
                document.body.setAttribute("style","background-size:cover;");
            }
        }
        setBodyStyleWidthAndHieght();
        window.onresize = setBodyStyleWidthAndHieght;
    }
var isTouch=window.matchMedia(“仅屏幕和(悬停:无)和(指针:粗略)”;
如果(isTouch.matches){
函数getHeight(){
返回屏幕高度;
}
函数getWidth(){
返回屏幕宽度;
}
var oldWidth=getWidth();
var oldHeight=getHeight();
函数setBodyStyleWidthAndHight(){
试一试{
如果(oldWidth==getHeight()&&oldHeight==getWidth()){
//设备已翻转;
设温度=宽度;
oldWidth=oldHeight;
旧高度=温度;
}

document.body.setAttribute(“样式”,OldWidth背景尺寸:封面;使图像延伸到边界之外。图像在Android上合适。请您附上一张屏幕截图,说明它应该是什么样子,封面是什么样子?您好,尝试添加图像bt是假设它需要声誉为10,因此不允许我添加图像。基本上发生的是我的图像e的宽度设置不正确。它超出了屏幕范围,即图像角的图标从左侧隐藏是的,我需要在整个屏幕上设置图像。背景尺寸:封面是否符合您的要求?