网站难以自适应

时间:2018-09-24 23:18:49

标签: html css mobile responsive-design frontend

我很难使该网站(phil-ga-surge.sh)响应移动。由于它只是一个登录页面,因此我不想使其变得过于复杂,因此只希望在更改屏幕大小时一切都就位。我确定这很简单,但是对于我的一生,我无法弄清楚。我正在画所有的空白。这是我到目前为止的内容:

* {
  box-sizing: border-box;
  margin: 0;
}

body, html {
  height: 100%;
  margin: 0;
}

.bgimg {
  background-image: url("https://res.cloudinary.com/dod6u4bjy/image/upload/v1536798847/water_kingdom_background.jpg");
  height: 100%;
  background-position: center;
  background-size: cover;
  position: relative;
  color: white;
  font-family: 'Merienda', cursive;
  font-size: 25px;
}

.nav {
  color: blue;
  text-decoration: none;
  list-style-type: none;
  display: flex;
  justify-content: space-between;
  width: 400px;
  padding-top: 10px;
}

.topleft {
  position: absolute;
  top: 0;
  left: 16px;
}

.header {
  color: white;
}

.heading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

hr {
  margin: auto;
  width: 40%;
}

#h3 {
  color: rgba(255, 255, 255, 0.5);
  -webkit-animation: flash linear 4s infinite;
  animation: flash linear 4s infinite;
}
@-webkit-keyframes flash {
  0% {
    opacity: 4;
  }
  50% {
    opacity: 0.4;
  }
  100% {
    opacity: 4;
  }
}
@keyframes flash {
  0% {
    opacity: 4;
  }
  50% {
    opacity: 0.4;
  }
  100% {
    opacity: 4;
  }
}

a:hover {
  color: darkgrey;
}


.logo {
  margin-top: 25px;
  height: 100px;
}

a {
  text-decoration: none;
  color: darkblue;
}

footer {
  text-align: center;
  color: white;
  position: fixed;
  bottom: 0;
  width: 100%;
}


@media all and (max-width: 480px) {
  .nav {
    display:inline-block;
  }
  .header {
    width: 100%;
  }
body, html {
  width: 100%;
}

}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link href="https://fonts.googleapis.com/css?family=Architects+Daughter" rel="stylesheet">
  <link rel="stylesheet" href="style.css" type="text/css"
</head>

<body>

  <div class="bgimg">
    <div class="topleft">

      <nav class="nav">
        <li> <a href="https://raijinstudiosabout.carrd.co">Raijin Studios</li></a>
        <li><a href="https://thewaterkingbook.carrd.co">About the Book</li></a>

      </nav>

    </div>
    <div class="heading">
      <h1 class="header">Announcing:<br> The Water King</h1>

      <hr>
      <h3 id="h3"></h3>
    </div>

  </div>

  <footer>©Raijin Studios</footer>
<script src="javascript.js"></script>
</body>

</html>

2 个答案:

答案 0 :(得分:1)

一切正常,只要我将<link rel="stylesheet" href="style.css" type="text/css"替换为<link rel="stylesheet" href="style.css" type="text/css" />

答案 1 :(得分:1)

问题是您的link标签未关闭:

<link rel="stylesheet" href="style.css" type="text/css"

将其更改为此:

<link rel="stylesheet" href="style.css" type="text/css" />