html - div 在小屏幕上消失

标签 html css

div 在小屏幕上消失。

如果屏幕变小,该 Div 应该分两部分显示。

在小屏幕上,div 是不可见的。

Visit &看到倒计时,它在小屏幕上消失了。

如何解决?

代码在这里:-

<html>
<head>
<title>
Maintenance in Progress
</title>
<style>
.timer {
  font-size: 60px;
  color: white;
  position: fixed;
  right: 500px;
  bottom: 0;
}
body {
    background-repeat: no-repeat;
    background-size: 100% 100%;
}
.utxt{
    position: fixed;
    width: 100%;
}
.circle{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.dtxt{
    position: absolute;
    bottom: 0;
    width: 30%;
}

</style>
</head>
<body background="maintenance/bg.png">
<img class="utxt" src="maintenance/utxt.png"></img>
<img class="circle" src="maintenance/circle.png"></img>
<img class="dtxt" src="maintenance/dtxt.png"></img>
<div class="timer" id="demo"></div>

<script>
// Set the date we're counting down to
var countDownDate = new Date("May 19, 2017 00:00:00").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

    // Get todays date and time
    var now = new Date().getTime();

    // Find the distance between now an the count down date
    var distance = countDownDate - now;

    // Time calculations for days, hours, minutes and seconds
    var days = Math.floor(distance / (1000 * 60 * 60 * 24));
    var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    var seconds = Math.floor((distance % (1000 * 60)) / 1000);

    // Output the result in an element with id="demo"
    document.getElementById("demo").innerHTML = days + "d " + hours + "h "
    + minutes + "m " + seconds + "s ";

    // If the count down is over, write some text 
    if (distance < 0) {
        clearInterval(x);
        document.getElementById("demo").innerHTML = "EXPIRED";
    }
}, 1000);
</script>

</body>
</html>

请帮帮我!

最佳答案

根据您的要求,代码位于此处:-

<html>
<head>
<title>
Maintenance in Progress
</title>
<style>
.timer {
  font-size: 60px;
  color: white;
  position: fixed;
  right: 500px;
  bottom: 0;
}
.stimer {                   <!--added-->
  font-size: 60px;
  color: white;
  position: fixed;
  right: 500px;
  bottom: 60px;
}
.bstimer {                  <!--added-->
  font-size: 60px;
  color: white;
  position: fixed;
  right: 500px;
  bottom: 0;
}
body {
    background-repeat: no-repeat;
    background-size: 100% 100%;
}
.utxt{
    position: fixed;
    width: 100%;
}
.circle{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.dtxt{
    position: absolute;
    bottom: 0;
    width: 30%;
}
@media (max-width: 900px) {             <!--added-->
    .timer {
       display: none;
    }
    .stimer {
       right:0;
    }
    .bstimer {
       right:0;
    }
}
@media (min-width: 900px) {         <!--added-->
    .stimer {
       display: none;
    }
    .bstimer {
       display: none;
    }
}
</style>
</head>
<body background="maintenance/bg.png">
<img class="utxt" src="maintenance/utxt.png"></img>
<img class="circle" src="maintenance/circle.png"></img>
<img class="dtxt" src="maintenance/dtxt.png"></img>
<div class="timer" id="demo"></div>
<div class="stimer" id="sdemo"></div></br>          <!--added-->
<div class="bstimer" id="bsdemo"></div>             <!--added-->

<script>
// Set the date we're counting down to
var countDownDate = new Date("May 19, 2017 00:00:00").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

    // Get todays date and time
    var now = new Date().getTime();

    // Find the distance between now an the count down date
    var distance = countDownDate - now;

    // Time calculations for days, hours, minutes and seconds
    var days = Math.floor(distance / (1000 * 60 * 60 * 24));
    var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    var seconds = Math.floor((distance % (1000 * 60)) / 1000);

    // Output the result in an element with id="demo"
    document.getElementById("demo").innerHTML = days + "d " + hours + "h "
    + minutes + "m " + seconds + "s ";

    // Output the result in an element with id="sdemo"                  (added)
    document.getElementById("sdemo").innerHTML = days + "d " + hours + "h ";

    // Output the result in an element with id="bsdemo"                 (added)
    document.getElementById("bsdemo").innerHTML = minutes + "m " + seconds + "s ";

    // If the count down is over, write some text 
    if (distance < 0) {
        clearInterval(x);
        document.getElementById("demo").innerHTML = "EXPIRED";
    }
}, 1000);
</script>

</body>
</html>

希望我能帮到你!

关于html - div 在小屏幕上消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43915410/

相关文章:

html - 如何使 css 运动路径响应?

html - 如何将内容居中并将背景颜色扩展到页面的 100%?

c# - 滚动时图像是如何下载的?

html - 将 3X3X3 布局中的 9 个 div 与每个 div 下的链接框对齐

HTML UL LI a href 链接不起作用

jquery - 使用 CSS 或 jQuery 仅水平扩展容器以防止垂直溢出

css - 如何包含 float 在容器 div 之外的 div

javascript - jQuery 在我获取它时减去 css 属性值

css - Chrome 中带有 rem 单位的媒体查询?

html - 如何将提交图像放入搜索栏的输入表单中?