当前位置:   article > 正文

H5 天气预报样式_h5 aweweather

h5 aweweather

本文主要是对h5样式和动画的熟练应用。要想实时显示天气预报,请自行百度...

实现的界面是


html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>天气预报</title>
  6. <link rel="stylesheet" href="weather.css">
  7. </head>
  8. <body>
  9. <header>
  10. <h2>郑州</h2>
  11. </header>
  12. <main>
  13. <img src="days/snow4.png" alt=""/>
  14. <p style="font-size:32px;">-13 ~ 2</p>
  15. <p style="font-size:26px;">小雪</p>
  16. <p style="font-size:20px;">微风</p>
  17. <p style="font-size:16px;">实时温度:13度 空气质量 13s 轻度污染</p>
  18. </main>
  19. <footer>
  20. <div>
  21. <p>周二</p>
  22. <img src="days/sleet.png" >
  23. <p>13-5</p>
  24. <p style="font-size:16px;"></p>
  25. <p>微风</p>
  26. </div>
  27. <div class="tom1">
  28. <p>周三</p>
  29. <img src="days/zhongyu.png">
  30. <p>13-5</p>
  31. <p style="font-size:16px;"></p>
  32. <p>微风</p>
  33. </div>
  34. <div class="tom2">
  35. <p>周四</p>
  36. <img src="days/qing.png">
  37. <p>13-5</p>
  38. <p style="font-size:16px;"></p>
  39. <p>微风</p>
  40. </div>
  41. </footer>
  42. <div class="clear"></div>
  43. </body>
  44. <script src="flake.js"></script>
  45. </html>
天气预报的样式

  1. html{
  2. height: 100%;
  3. }
  4. body{
  5. height: 100%;
  6. margin: 0;
  7. background: linear-gradient(to bottom,cornflowerblue,white) no-repeat;
  8. font-family: "微软雅黑";
  9. overflow: hidden;
  10. }
  11. header{
  12. text-align: center;
  13. width: 100%;
  14. height: 100px;
  15. color: #fff;
  16. }
  17. main{
  18. text-align: center;
  19. color: #fff;
  20. }
  21. /*标签的宽度= 边框的宽度+内容的宽度+内边距
  22. 其中 设定的宽度为内容的宽度
  23. 当设定的box-size:border-box的时候,标签的宽度就等于设定的宽度*/
  24. footer{
  25. width: 70%;
  26. color: #fff;
  27. padding-top: 100px;
  28. margin: 0px auto;
  29. }
  30. p{
  31. line-height: 10px;
  32. }
  33. footer div{
  34. text-align: center;
  35. width: 33.33%;
  36. float: left;
  37. border-right: 1px solid #fff;
  38. box-sizing: border-box;
  39. }
  40. footer div:nth-child(3){
  41. border: 0;
  42. }
  43. /*.tom{
  44. text-align: center;
  45. width: 33.33%;
  46. float: left;
  47. border-right: 1px solid #fff;
  48. box-sizing: border-box;
  49. }
  50. .tom1{
  51. text-align: center;
  52. float: left;
  53. width: 33.33%;
  54. border-right: 1px solio0-d #fff;
  55. box-sizing: border-box;
  56. }
  57. .tom2{
  58. text-align: center;
  59. float: left;
  60. width: 33.33%;
  61. box-sizing: border-box;
  62. }*/
  63. div img{
  64. height: 64px;
  65. width: 64px;
  66. }
  67. .clear{
  68. clear: both;
  69. }

动态雪花的js

  1. function flake(){
  2. // 创建img标签
  3. var f = document.createElement("img");
  4. // 获取浏览器的高度和宽度
  5. var h = document.documentElement.clientHeight;
  6. var w = document.documentElement.clientWidth;
  7. var left =w * Math.random();
  8. var top = h * Math.random();
  9. f.src = "flake.png";
  10. f.style.position = "absolute";
  11. f.style.left = left + "px";
  12. f.style.top = top + "px";
  13. //随机按比例缩放
  14. f.style.transform = "scale(" + Math.random() / 2 +")";
  15. f.style.zIndex = "-100";
  16. // 给body添加img标签
  17. document.body.appendChild(f);
  18. function down(){
  19. top = top + 10;
  20. left = left + 5;
  21. if(top > h ) top = -100;
  22. if(left > w) left = -100;
  23. f.style.left = left + "px";
  24. f.style.top = top + "px";
  25. }
  26. setInterval(down,100);
  27. }
  28. flake();
  29. for(var i=0; i<200;i++){
  30. flake();
  31. }



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/906590
推荐阅读
相关标签
  

闽ICP备14008679号