【问题标题】:My height for my page does not fill full height? How do I make it responsive?我的页面高度没有填满整个高度?如何让它响应?
【发布时间】:2020-06-27 21:47:56
【问题描述】:

我的身高反应迟钝。我引用了这个问题:

Why is min-height not working?

但它仍然无法正常工作。我要参考的网站是http://horsescowsandcemeteries.com/

我希望它适用于台式机和移动设备。谢谢。

Vh 不工作。

【问题讨论】:

  • 您到底想要缩放什么?该网站似乎已经响应了。
  • 你必须提供一个你的问题的例子,因为你肯定错过了你的代码中的很多点。请阅读:stackoverflow.com/help/how-to-ask

标签: javascript css height


【解决方案1】:

您可以使用“viewport”元标记来缩放您的网站,类似于浏览器版本。只需将下面的代码放入head 元素中即可。

<meta name="viewport" content="width=device-width, initial-scale=1.0">


如果你想在缩放时修复body背景,你可以使用这个:

body {
    height: fit-content;
}

Before/After

【讨论】:

    【解决方案2】:

    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; 添加到您的 HTML 并添加尝试此 css

    /*Game Play Screen */
    
    body {
      display: flex;
      flex-direction: column;
      margin: auto;
      border: 3px solid green;
      padding: 10px;
      background-image: url(images/road-bg.jpg);
      background-size: cover;
      font-family: "Krona One";
      text-align: center;
    }
    
    main {
      display: flex;
      flex: 1;
      margin-bottom: 25px;
    }
    
    #container {
      display: flex;
      flex: 1;
      justify-content: space-around;
    }
    
    .team-one, .team-two {
      width: 50%;
    }
    
    #left-side,
    #right-side {
      display: flex;
      flex: 1;
      height: 100%;
      flex-direction: column;
    }
    
    #instructions {
      margin-bottom: 2em;
      text-align: center;
      background-color: green;
      font-size: 140%;
    }
    
    #instructionsButton {
      background-color: green;
      color: white;
      padding: 0.5em 1em 0.5em 1em;
      text-decoration: none;
      font-size: 1.5em;
      border-radius: 10px;
    }
    
    .teamBox {
      color: white;
      background: #333;
      padding: 1em;
      border-radius: 5px;
      border: 6px solid white;
      width: 160px;
      height: 80px;
      margin-bottom: 1em;
      display: inline-block;
      -webkit-box-shadow: 3px 3px 5px 0px rgba(0, 0, 0, 0.44);
      -moz-box-shadow: 3px 3px 5px 0px rgba(0, 0, 0, 0.44);
      box-shadow: 3px 3px 5px 0px rgba(0, 0, 0, 0.44);
      margin: 5em auto;
    }
    
    .teamBox h3,
    p {
      margin-top: 0;
      margin-bottom: 0;
    }
    
    #scoreTotalTeamOne,
    #scoreTotalTeamTwo {
      font-size: 2.5em;
    }
    
    #endButton {
      background-color: #be1e2d;
      color: white;
      padding: 0.5em 1em 0.5em 1em;
      text-decoration: none;
      font-size: 2em;
      border-radius: 10px;
      margin-bottom: 2em;
    }
    
    .gameplaybutton {
      width: 200px;
      height: 200px;
      margin: auto;
    }
    
    /* First breakpoint, elimates the road */
    @media only screen and (max-width: 675px) {
      body {
        height: auto;
        background: url(images/road-bg-sm.jpg);
        background-size: cover;
      }
      .teamBox {
        width: 100px;
        height: 100px;
      }
     #instructionsButton{
       font-size: 1em;
     }
    }
    
    /* Second breakpoint */
    @media only screen and (max-width: 550px) {
      .gameplaybutton {
        width: 150px;
        height: 150px;
      }
    }
    
    

    【讨论】:

      猜你喜欢
      • 2020-02-16
      • 1970-01-01
      • 2017-10-19
      • 2016-02-18
      • 2020-11-24
      • 2012-07-23
      • 2020-10-30
      • 2017-11-01
      • 1970-01-01
      相关资源
      最近更新 更多