Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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
Html 背景图像不';不能在小型设备上显示CSS_Html - Fatal编程技术网

Html 背景图像不';不能在小型设备上显示CSS

Html 背景图像不';不能在小型设备上显示CSS,html,Html,背景图像不会显示在小型设备上。我有一个通过CSS放大的背景图像,但当屏幕变小时,背景图像消失,变成白色。我正在尝试制作一个应用程序,因此它需要在所有设备和尺寸上工作。当它不放大时,它确实工作得很好。我已将代码粘贴到下面。谢谢 * {-webkit-tap-highlight-color: rgba(0, 0, 0, 0):} body { -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to

背景图像不会显示在小型设备上。我有一个通过CSS放大的背景图像,但当屏幕变小时,背景图像消失,变成白色。我正在尝试制作一个应用程序,因此它需要在所有设备和尺寸上工作。当它不放大时,它确实工作得很好。我已将代码粘贴到下面。谢谢

* {-webkit-tap-highlight-color: rgba(0, 0, 0, 0):}

body {
-webkit-touch-callout: none;
/* prevent callout to copy image, etc when tap to hold */
-webkit-text-size-adjust: none;
/* prevent webkit from resizing text to fit */
-webkit-user-select: none;
/* prevent copy paste, to allow, change 'none' to 'text' */
background-color: #E4E4E4;
);
background-attachment: fixed;
}

/* Portrait layout (default) */

.app {
position: absolute;
/* position in the center of the screen */
background-position: center;
position: relative;
bottom: -300px;
font-family: 'Roboto', sans-serif;
}

/* Landscape layout (with min-width) */

@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {

h1 {
    font-size: 90px;
    font-weight: normal;
    margin: 0px;
    overflow: visible;
    padding: 0px;
    text-align: center;
    color: white;
    font-family: 'Roboto', sans-serif;
}
p {
    color: blue;
    font-family: 'Roboto', sans-serif;
    font-size: 15px;
    text-align: center;
    color: white;
}
.event {
    border-radius: 4px;
    -webkit-border-radius: 4px;
    color: #FFFFFF;
    font-size: 12px;
    margin: 0px 30px;
    padding: 2px 0px;
}
.createAnAccount {
    padding-bottom: 10px;
    padding-top: 10px;
    font-size: 15px;
}
.logintable {
    text-align: center;
}
.login {
    padding-bottom: 10px;
    padding-top: 10px;
    font-size: 15px;
}
.event.listening {
    background-color: #333333;
    display: block;
}
.event.received {
    background-color: #4B946A;
    display: none;
}
@keyframes fade {
    from {
        opacity: 1.0;
    }
    50% {
        opacity: 0.4;
    }
    to {
        opacity: 1.0;
    }
}
@-webkit-keyframes fade {
    from {
        opacity: 1.0;
    }
    50% {
        opacity: 0.4;
    }
    to {
        opacity: 1.0;
    }
}
.blink {
    animation: fade 3000ms infinite;
    -webkit-animation: fade 3000ms infinite;
}
.bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -999;
}
.background {
    background: #22313F;
    background-image: url(https://i.ytimg.com/vi/b7WD-
    SpNX_I/maxresdefault.jpg);
    background-size: cover;
    width: 100%;
    height: 100%;
    animation: zoom 12s forwards ease-out;
下面是Html代码

<body>
    <div class="bg">
        <div class="background"></div>
    </div>
<body>

您的@media查询具有最小像素限制。如果删除此项,它将起作用。 所以改变这条线

@media screen and (min-aspect-ratio: 1/1) and (min-width:400px)
进入这个

@media screen and (min-aspect-ratio: 1/1)

通过设置最小宽度,仅当视口宽度为400像素或更宽时,才应用此背景更改。

您的@media查询具有最小像素限制。如果删除此项,它将起作用。 所以改变这条线

@media screen and (min-aspect-ratio: 1/1) and (min-width:400px)
进入这个

@media screen and (min-aspect-ratio: 1/1)

通过设置“最小宽度”(min width),仅当视口宽度为400像素或更宽时,才应用此背景更改。

谢谢,但是,它似乎不起作用。我已经减少了像素,然后用你的代码替换了它,但是运气不好。你是说当你删除它并调整屏幕大小时,它仍然在400像素以下变白?检查这把小提琴,我删除了最小宽度和纵横比。它从不给我白色。你能检查一下并告诉我这是否发生在你的电脑上吗?在fiddle上为我工作一定与程序有关。谢谢你在更改后试图清除浏览器缓存吗?也许它还用旧的?ctrl shift r将清空缓存并硬加载页面。谢谢,但是,它似乎不起作用。我已经减少了像素,然后用你的代码替换了它,但是运气不好。你是说当你删除它并调整屏幕大小时,它仍然在400像素以下变白?检查这把小提琴,我删除了最小宽度和纵横比。它从不给我白色。你能检查一下并告诉我这是否发生在你的电脑上吗?在fiddle上为我工作一定与程序有关。谢谢你在更改后试图清除浏览器缓存吗?也许它还用旧的?ctrl-shift r将清空缓存并硬重新加载页面。