输入城市名搜索查询天气预报效果代码

代码语言:html

所属分类:其他

代码描述:输入城市名搜索查询天气预报效果代码

代码标签: 输入 城市名 搜索 查询 天气 预报

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


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

<head>

  <meta charset="UTF-8">
  

  
  
  
  
<style>
html {
  width: 100%;
  height: 100vh;
  font-family: "Poppins", sans-serif;
}

body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  background: #fffef4;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #8b8b8b;
  transition: all 1s;
}

.weather__container {
  width: 500px;
  height: 230px;
  background: #fff;
  border-radius: 20px;
  position: relative;
  box-shadow: 0 0 20px 10px rgba(0, 0, 0, 0.05);
}
.weather__container #units__toggle {
  position: absolute;
  top: 5%;
  right: 5%;
  display: flex;
  z-index: 10;
}
.weather__container #units__toggle #celsius,
.weather__container #units__toggle #fahrenheit {
  margin-right: 10px;
  padding: 8px 11px;
  cursor: pointer;
  border: none;
  background: #fff;
  border-radius: 100px;
}
.weather__container #units__toggle .active {
  color: #fff;
  background: #89d3c5 !important;
  pointer-events: none;
}
.weather__container #weather__icon {
  position: absolute;
  top: 50%;
  left: -10%;
  transform: translate(0%, -50%);
  width: 180px;
  height: 180px;
}
.weather__container #weather__icon svg {
  width: 100%;
  overflow: visible;
}
.weather__container #weather__icon #clear-sky,
.weather__container #weather__icon #rain,
.weather__container #weather__icon #snow,
.weather__container #weather__icon #thunderstorm,
.weather__container #weather__icon #mist,
.weather__container #weather__icon #broken-clouds {
  opacity: 0;
}
.weather__container #weather__icon .show {
  opacity: 1;
}
.weather__container .box1 {
  position: absolute;
  top: 40%;
  left: 30%;
  transform: translate(0%, -50%);
  width: 70%;
  height: 80%;
  display: flex;
  align-items: center;
}
.weather__container .box1 #location__name {
  color: #555555;
  font-size: 1.8rem;
}
.weather__container .box1 #current__temperature {
  position: absolute;
  top: 50%;
  right: 15%;
  transform: translate(0%, -50%);
  font-size: 2rem;
  font-weight: 200;
}
.weather__container .box2 {
  position: absolute;
  top: 80%;
  left: 30%;
  transform: translate(0%, -50%);
  width: 40%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.weather__container .box2 #minmax__temperature {
  margin-left: 30px;
  position: relative;
}
.weather__container .box2 #minmax__temperature::before {
  content: "";
  position: absolute;
  top: -5px;
  left: -40px;
  display: block;
  background-image: url(//repo.bfw.wiki/bfwrepo/icon/637c3d88d00b0.png);
  background-size: contain;
  width: 35px;
  height: 35px;
  margin-right: 10px;
}
.weather__container .box2 #humidity {
  position: relative;
}
.weather__container .box2 #humidity::before {
  content: "";
  position: absolute;
  top: -5px;
  left: -40px;
  display: block;
  background-image: url(//repo.bfw.wiki/bfwrepo/icon/637c3dbb08ce7.png);
  background-size: contain;
  width: 35px;
  height: 35px;
}

.search__input {
  width: 500px;
  margin-top: 100px;
}
.search__input form#city__form {
  width: 100%;
  text-align: center;
}
.search__input form#city__form .form__group input#city {
  width: 40%;
  margin: 10px;
  padding: 10px;
  border: none;
  outline: none;
  border-radius: 50px;
  box-shadow: 0 0 20px 10px rgba(0, 0, 0, 0.05);
  text-align: center;
  color: #8b8b8b;
  font-size: 1rem;
  font-weight: 300;
}
.search__input form#city__form .notfound__text {
  display: none;
}
</style>



</head>

  <body>
    <main>
      <div class="weather__container">
        <div id="units__toggle">
          <button id="celsius" class="active">C</button>
          <button id="fahrenheit">F</button>
        </div>
        <div id="weather__icon">
          <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 290 290">
            <defs>
              <linearGradient id="linear-gradient" x1="145.2" y1="17.8" x2="145.2" y2="315.1" gradientUnits="userSpaceOnUse">
                <stop offset="0" stop-color="#f2c94c" />
                <stop offset="1" stop-color="#f2994a" />
              </linearGradient>
              <linearGradient id="linear-gradient-2" x1="123.9" y1="29.7" x2="123.9" y2="283.5" xlink:href="#linear-gradient" />
              <linearGradient id="linear-gradient-3" x1="178" y1="308.5" x2="107.6" y2="89.4" gradientUnits="userSpaceOnUse">
                <stop offset="0" stop-color="#b8e9e6" />
                <stop offset="1" stop-color="#fff" />
              </linearGradient>
              <linearGradient id="linear-gradient-4" x1="205" y1="270.8" x2="80.8" y2="54.8" xlink:href="#linear-gradient-3" />
              <linearGradient id="linear-gradient-5" x1="137.8" y1="171.3" x2="62.7" y2="26.6" xlink:href="#linear-gradient-3" />
              <linearGradient id="linear-gradient-6" x1="189" y1="306.7" x2="125.4" y2="109" xlink:href="#linear-gradient-3" />
              <linearGradient id="linear-gradient-7" x1="205" y1="230.2" x2="80.8" y2="14.2" xlink:href="#linear-gradient-3" />
              <linearGradient id="linear-gradient-9" x1="145.2" y1="127.7" x2="145.2" y2="326.2" gradientUnits="userSpaceOnUse">
                <stop offset="0" stop-color="#ffca00" />
                <stop offset="1" stop-color="#fff" />
              </linearGradient>
              <linearGradient id="linear-gradient-10" x1="203.7" y1="230.2" x2="79.4" y2="14.2" xlink:href="#linear-gradient-3" />
              <linearGradient id="linear-gradient-11" x1="109.6" y1="235.6" x2="73.3" y2="150.4" gradientUnits="userSpaceOnUse">
                <stop offset="0" stop-color="#a4bcda" />
                <stop offset="1" stop-color="#d2e1ff" />
              </linearGradient>
              <linearGradient id="linear-gradient-13" x1="194.2" y1="191.7" x2="157.9" y2="106.6" xlink:href="#linear-gradient-11" />
              <linearGradient id="linear-gradient-15" x1="194.2" y1="280.4" x2="157.9" y2="195.3" xlink:href="#linear-gradient-11" />
              <clipPath id="clip-path">
                <path id="mask-thunder" fill="none" d="M110 112h71v169h-71z" />
              </clipPath>
            </defs>

            <g id="weather-icons">
              <circle class="show" id="clear-sky" cx="145.2" cy="145.2" r="145.2" fill="url(#linear-gradient)" />
              <g id="broken-clouds">
                <path id="broken-clouds-1" d="M180 69A62 62 0 0063 94h-1a62 62 0 000 125h115a75 75 0 003-150z" fill="url(#linear-gradient-5)" />
                <path id="broken-clouds-2" d="M216 135a64 64 0 00-121 27 64 64 0 100 128h118a78 78 0 003-155z" fill="url(#linear-gradient-6)" />
              </g>
                <g id="rain">
    <path d="M206 37A71 71 0 0073 67a71 71 0 100 142h130a86 86 0 003-172z" fill="url(#linear-gradient-7)" />
    <path class="raindrops" fill="none" stroke="#9bdadd" stroke-linecap="round" stroke-miterlimit="10" stroke-width="8" stroke-dasharray="32 21" d="M90 190l-68 68" />
    <path class="raindrops" fill="none" stroke="#9bdadd" stroke-linecap="round" stroke-miterlimit="10" stroke-width="8" stroke-dasharray="32 21" d="M133 190l-68 68" />
    <path class="raindrops" fill="none" stroke="#9bdadd" stroke-linecap="round" stroke-miterlimit="10" stroke-width="8" stroke-dasharray="32 21" d="M177 190l-69 68" />

  </g>
              <g id="thunderstorm">
                <path id="thunderstorm-cloud" d="M208 37A71 71 0 0074 67a71 71 0 100 142h130a86 86 0 004-172z" fill="url(#linear-gradient-7)" />
                <g clip-path="url(#clip-path)">
                  <path id="thunderstorm-thunder" fill="url(#linear-gradient-9)" d="M175 112l-65 62 33 44-27 63 65-64-35-43 29-62z" />
                </g>
              </g>
              <g id="snow">
                <path id="snow-cloud" d="M206 37A71 71 0 0073 67a71 71 0 100 142h130a86 86 0 003-172z" fill="url(#linear-gradient-10)" />
                <g class="snow-1" fill="url(#linear-gradient-11)">
                  <path d="M98 199l-7 4a1 1 0 00-1 1v8a1 1 0 001 1l7 4a1 1 0 001 0l6-4a1 1 0 001-1v-8a1 1 0 00-1-1l-6-4a1 1 0 00-1 0zm6 6v7l-6 3-6-3v-7l6-3z" />
                  <path d="M125 215l-9 3-4-3v-13l4-3 9 2a1 1 0 000-2l-6-1 6-4a1 1 0 00-1-2l-6 4 1-7a1 1 0 10-2 0l-2 8-4 3-12-7v-5l6-6a1 1 0 000-2 1 1 0 00-1 0l-5 5v-7a1 1 0 00-2 0v7l-5-5a1 1 0 00-1 0 1 1 0 000 2l6 6v5l-11 7-5-3-2-8a1 1 0 00-2-1 1 1 0 000 1l1 7-6-4a1 1 0 10-1 2l6 4-6 1a1 1 0 000 2l9-2 4 3v13l-4 3-9-3a1 1 0 000 2l6 2-6 4a1 1 0 001 2l6-4-1 7a1 1 0 000 1 1 1 0 001 0 1 1 0 001-1l2-9 5-2 11 6v6l-6 6a1 1 0 000 2 1 1 0 001 0l5-5v7a1 1 0 002 0v-7l5 5a1 1 0 001 0 1 1 0 000-2l-6-6v-6l12-6 4 3 3 8a1 1 0 001 1 1 1 0 001-1l-2-7 6 4a1 1 0 001-1 1 1 0 000-1l-6-4 6-2a1 1 0 000-2zm-16 0l-11 7-11-7v-13l11-7 11 7z" />
                </g>
                <g class="snow-1" fill="url(#linear-gradient-.........完整代码请登录后点击上方下载按钮下载查看

网友评论0