html - 响应式设计模式未显示正确的移动体验

标签 html css responsive-design

我一直在用 HTML 和 CSS 为我的书设计一个新封面。完成后,我在 Firefox 和 Google Chrome 的响应式设计模式下看到了结果,但是当我在手机上使用 Chrome(顺便说一句,它是 Galaxy s3)打开网站时,这是一个完全不同的故事。 这是我网站的 link

我希望它和响应式设计模式下的一样

这是我的 HTML 和 CSS 文件:

@font-face{
  font-family: 'halogen';
  src: url(https://ali-xoerex.github.io/static/fonts/halogen.otf);
}

@keyframes iwoz{
  to{
    text-shadow: 1px 1px green;
    color: green;
  }
}

body{
  background: url(https://ali-xoerex.github.io/static/img/macos.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  font-family: 'Roboto', sans-serif;
}

.item , #clock{
  margin-top: 3px;
}

.navigation{
  width: 100%;
  background:  rgba(109, 110, 112,0.3);
  top: 0;
  left: 0;
  position: fixed;
  height: auto;
  color: whitesmoke;
}

.title{
  margin-top: 3%;
  height: 80vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header{
  border-bottom: 1px solid gray;
  width: 100%;
  display: flex;
  flex-direction: row;
  border-top: 1px solid #ebebeb;
  border-top-left-radius: 1%;
  border-top-right-radius: 1%;
  background: -moz-linear-gradient(to top,#ebebeb, #d5d5d5);
  background: -webkit-linear-gradient(to top,#ebebeb, #d5d5d5);
  background: -o-linear-gradient(to top,#ebebeb, #d5d5d5);
  background: linear-gradient(to top,#ebebeb, #d5d5d5);
}

.close{
  text-indent: -99999px;
  border: 1px solid #ff5c5c;
  background: #ff5c5c;
  display: flex;
  padding-left: 2px;
  padding-bottom: 2px;
  justify-content: center;
  border-radius: 50%;
  font-size: 9px;
  height: 10px;
  width: 10px;
}

.close:hover{text-indent: 0;}
.minimize:hover{text-indent: 0;}
.size:hover{text-indent: 0;}

.size{
  text-indent: -99999px;
  border: 1px solid #ffbd4c;
  background: #ffbd4c;
  display: flex;
  padding-left: 2px;
  padding-bottom: 2px;
  justify-content: center;
  border-radius: 50%;
  font-size: 9px;
  height: 10px;
  width: 10px;
}

.minimize{
  text-indent: -99999px;
  border: 1px solid  #00ca56;
  background:  #00ca56;
  display: flex;
  padding-left: 2px;
  padding-bottom: 2px;
  justify-content: center;
  border-radius: 50%;
  font-size: 9px;
  height: 10px;
  width: 10px;
}

.h{
  margin-left: 45%;
}

.buttons{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center; 
  min-width: 55px;
}

.right{
  margin-right: 10px;
}


.content{
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  font-family: 'halogen';
  font-size: 80px;
  animation: iwoz 2s forwards;
}

.window{
  border: 2px solid #ebebeb;
  background: rgba(109, 110, 112,0.3);
  border-radius: 1%;
  width: 800px;
  height: 70%;
  max-height: auto;
  margin-bottom: 4%;
}

.main{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.icons{
  display: flex;
  justify-content: space-around;
}

.left{
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  min-width: 85px;
  margin-left: 10px;
}

.dock{
  width: 50%;
  height: auto;
  border-top-left-radius: 2%;
  border-top-right-radius: 2%;
  background: rgba(109, 110, 112,0.8);
  left: 25%;
  bottom: 0;
  position: fixed;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>IWoz Cover</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" media="screen" href="static/css/index.css" />
  <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> 
</head>
<body>
    <div class="navigation">
      <div class="main">
          <div class="left">
              <div class="logo"><img src="https://ali-xoerex.github.io/static/img/apple.png" alt=""></div>
              <div class="item">IWoz</div>
          </div>
          <div id="clock" class="right">
          </div>
      </div>
    </div>
    <div class="title">
      <div class="window">
        <div class="header">
          <div class="buttons" style="display:flex;flex-direction:row">
            <div class="close">
              X
            </div>
            <div class="size">
                -
            </div>
            <div class="minimize">
                +
            </div>
          </div>  
          <div class="h">IWoz</div>
        </div>
        <div class="content">
          IWoz
        </div>
      </div>
    </div>
    <div class="dock">
      <div class="icons">
        <a href="https://github.com/Ali-Xoerex/Ali-Xoerex.github.io" role="button"><img src="https://ali-xoerex.github.io/static/img/github.png" alt=""></a>
        <a href="https://ali-xoerex.github.io/chapters/1/1.html" role="button"><img src="https://ali-xoerex.github.io/static/img/book.png" alt=""></a>
      </div>
    </div>
    <script>
      function update_clock(){
        let days = ["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"]
        let date = new Date();
        let clock = date.toLocaleTimeString();
        document.getElementById('clock').innerText = days[date.getDay()]+' '+clock
      }
      setInterval(update_clock,1000);
    </script>
</body>
</html>

我们将不胜感激

最佳答案

如果您检查背景图像所依赖的 body 元素的高度,它不会完全覆盖整个屏幕。只需添加 height:100vh;到你的 body 元素。

关于html - 响应式设计模式未显示正确的移动体验,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51571572/

相关文章:

html - div 元素的 CSS 边框图像边框

twitter-bootstrap - 中屏幕的 Bootstrap 位置布局错误

css - 在网格系统之外扩展响应元素?

javascript - 完整日历事件源数据在参数中传递空值

Javascript 应用的 CSS3 过渡不适用于新元素

javascript - 视频播放完毕后,播放按钮不会开始播放视频

html - 向左浮动,垂直居中,显示表格单元格不起作用

html - 长标题破坏了响应式屏幕网格布局的设计

javascript - 如何将带有 "onclick"的 javascript 输出到文本字段中?

javascript - 检查基于下拉问题的复选框