如何在天气状况旁边移动天气图标?

时间:2017-10-30 23:53:12

标签: javascript html css

我的图标悬挂在屏幕左下角。我很想知道>最快的方式将它放在天气条件旁边(在你的>位置下方)。

链接到Codepen

<div class="container">
  <h1 class=" text-center"> Your Local Current Weather</h1> <br>
  <div>
    <h2 id="location" class="text-center"> </h2>
    <h2 id="condition" class="text-center">
    </h2>

    <h2 class="text-center" style="cursor: pointer">Temperature: <span id="temperature" class="toggle"></span></h2>
    <canvas id="icon" width="100" height="100"></canvas>

  </div>
</div>

1 个答案:

答案 0 :(得分:1)

在当地当前天气之后放置Canvas标记:

<body>
  <div class="container">
  <h1 class= " text-center"> Your Local Current Weather</h1> <br>
    <canvas id="icon" width="100" height="100"></canvas>
  <div>
  <h2 id = "location" class = "text-center"> </h2>
  <h2 id= "condition" class="text-center">
     </h2>

  <h2 class="text-center" style="cursor: pointer">Temperature: <span id="temperature" class="toggle"></span></h2> 

    </div>
  </div>

</body>

并在CSS中添加:

#icon {
 position: relative;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -10%)
}

我已将其更新HERE