我的网站是响应式的,但它没有做出正确尺寸的反应

时间:2018-02-22 22:25:08

标签: html html5 css3 media-queries responsive

所以我做了一个响应式网站,但网站没有改变它应该。 我在下面链接的网站显示,在我的Iphone 6 Plus上它应该格式正确,但当我在我的iphone上检查它的平板电脑查看模式的网站。

你可以在这里查看我的意思http://quirktools.com/screenfly/#u=http%3A//maartennauta.com&w=1024&h=600&s=1

CSS代码



html * {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: 'Montserrat', sans-serif;
}

body {
  margin-left: auto;
  margin-right: auto;
}

header {
  padding-bottom: 1px;
}

footer {
  text-align: center;
}

.logo {
  border-radius: 10px;
  height: 100px;
  margin-top: 15px;
  margin-bottom: 5px;
  width: 178px;
  margin-left: auto;
  margin-right: auto;
  display: block;
}

img {
  width: 100%;
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.style-nav ul {
  list-style-type: none;
  text-align: center;
}

.style-nav ul li a {
  text-decoration: none;
  color: #2F322A;
  text-align: center;
  display: block;
  text-transform: uppercase;
  padding: 8px;
}

.style-nav ul li a:hover {
  color: black;
  text-shadow: 2px 2px 10px #000000;
  transition: 0.5s ease;
  -webkit-transition: 0.5s ease;
}

.hero {
  background-image: url(../Images/Background.jpg);
  background-size: cover;
  padding-top: 15px;
  padding-left: 20px;
  padding-right: 20px;
  padding-bottom: 50px;
  color: #FFFFFF;
  text-align: center;
}

.infobox-tan {
  background-color: #C29D73;
  color: #FFFFFF;
  padding: 30px 20px 60px;
  text-align: center;
}

.infobox-grey {
  background-color: #717A84;
  color: #FFFFFF;
  padding: 30px 20px 60px;
  text-align: center;
}

.row:before,
.row:after {
  content: "";
  display: table;
  color: #FFFFFF;
  text-align: center;
}

h1.small {
  font-size: 30px;
  text-transform: uppercase;
  font-weight: 200;
  margin-bottom: 60px;
}

h2 {
  font-size: 25px;
  text-transform: uppercase;
  font-weight: 100;
  margin-bottom: 20px;
  padding: 30px
}

h3 {
  font-size: 16px;
  text-transform: uppercase;
  font-weight: 200;
  margin-bottom: 60px;
}

h4 {
  font-size: 16px;
  font-weight: 200;
  margin-bottom: 35px;
}

p {
  font-size: 15px;
  text-transform: none;
  font-weight: 20;
  margin-bottom: 60px;
}

p.footertext {
  color: gray;
  font-size: 15px;
  text-transform: none;
  font-weight: 20;
  margin-top: 20px;
  margin-bottom: 20px;
}

.button {
  border-radius: 30px;
  border: 2px #FFFFFF solid;
  padding: 8px 15px;
  color: #FFFFFF;
  text-decoration: none;
  margin-bottom: 30px;
}

.button:hover {
  color: #242424;
  border: 2px #242424 solid;
  transition: 0.5s ease;
  -webkit-transition: 0.5s ease;
}

.row:after {
  clear: both;
}

.col {
  width: 100%;
}


/*Tablet View*/

@media (min-width: 700px) {
  .style-logo {
    float: center;
  }
  body {
    max-width: 778px;
  }
  .style-nav ul li {
    display: inline-block;
  }
  h1.normal {
    font-size: 57px;
    text-transform: uppercase;
    font-weight: 200;
    margin-bottom: 60px;
  }
  .row:before,
  .row:after {
    content: "";
    display: table;
    padding: 5px;
    color: #FFFFFF;
    text-align: center;
  }
  .col-tablet {
    width: 50%;
  }
  .col {
    float: left;
    padding-bottom: 14px;
    padding-left: 7px;
    padding-right: 7px;
  }
}


/*Desktop View*/

@media (min-width: 1024px) {
  .style-logo {
    float: center;
  }
  .style-nav {
    float: center;
  }
  .col-desktop {
    width: 25%;
  }
  body {
    max-width: 1200px;
  }
}

<!doctype html>
<html>

<head>
  <link href="CSS/Styles.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
  <meta charset="utf-8">
  <title>Home</title>
</head>

<body>
  <header>
    <div class="row">
      <div class="col">
        <img class="logo" src="Images/Logo company.png" alt="Logo">
        <nav class="style-nav">
          <ul>
            <li><a href="#">Education</a></li>
            <li><a href="#">Photos</a></li>
            <li><a href="#">Services</a></li>
          </ul>
        </nav>
      </div>
    </div>
  </header>
  <main>
    <div class="row">
      <div class="col">
        <div class="hero">
          <h3>Editor's Choice</h3>
          <h4>Maarten Nauta</h4>
          <h1 class="normal small">Webdesign</h1>
          <a href="#" class="button">Read More</a>
        </div>
      </div>
    </div>

    <div class="row">
      <div class="col col-tablet">
        <div class="infobox-tan">
          <h2>Education</h2>
          <p>And a summary of my achievements</p>
          <a href="#" class="button">Read More</a>
        </div>
      </div>
      <div class="col col-tablet">
        <div class="infobox-grey">
          <h2>Services</h2>
          <p>Graphic/Web design - Video/Photo editing</p>
          <a href="#" class="button">Read More</a>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col col-tablet col-desktop"><img src="Images/Stock-img-1.jpeg.jpg" alt="1"></div>
      <div class="col col-tablet col-desktop"><img src="Images/Stock-img-2.jpeg.jpg" alt="2"></div>
      <div class="col col-tablet col-desktop"><img src="Images/Stock-img-3.jpeg.jpg" alt="3"></div>
      <div class="col col-tablet col-desktop"><img src="Images/Stock-img-4.jpeg.jpg" alt="4"></div>
    </div>

  </main>
  <footer>
    <div class="row">
      <div class="col">
        <p class="footertext">©2018 Maarten Nauta</p>

      </div>
    </div>
  </footer>
</body>

</html>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

您错过了viewport meta tag

  

(...)Apple推出了&#34; viewport元标记&#34;在Safari iOS中让   Web开发人员控制视口的大小和比例。很多别的   移动浏览器现在支持此标记,但它不属于任何标记   网络标准。 Apple的文档很好地解释了Web的方式   开发人员可以使用此标记,但我们必须做一些侦探工作   弄清楚如何在Fennec中实现它。例如,   Safari的文档说内容是一个以逗号分隔的列表,&#34;   但现有的浏览器和网页使用逗号,分号,   和空格作为分隔符。

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

答案 1 :(得分:1)

您的iPhone每英寸像素数比标准桌面屏幕更多,实际上> 700像素宽。要获取将像素视为屏幕大小单位的网页,您需要meta viewport tag

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

使用此标记,您的媒体查询将像屏幕标准72 ppi一样运行。