亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

CSS極坐標(biāo)的實(shí)例代碼

  發(fā)布時(shí)間:2021-06-03 16:57:51   作者:阿阿啊啊阿阿豪   我要評(píng)論
項(xiàng)目有圖表方面的需求,其中有做衛(wèi)星定位的圖形,需要制作極坐標(biāo)來顯示當(dāng)前北半球或南半球的衛(wèi)星分布情況,本文主要介紹了CSS極坐標(biāo)的實(shí)例代碼,分享給大家,感興趣的可以了解一下

前言

項(xiàng)目有圖表方面的需求,其中有做衛(wèi)星定位的圖形,需要制作極坐標(biāo)來顯示當(dāng)前北半球或南半球的衛(wèi)星分布情況。第一時(shí)間想到了echarts的極坐標(biāo),找到示例,雖然滿足了部分需求,但是極坐標(biāo)是由canvs畫的,衛(wèi)星有自己的編號(hào),所以難以辨析每個(gè)點(diǎn)對應(yīng)的衛(wèi)星編號(hào)。于是就想到了自己去用CSS畫極坐標(biāo)

提示:以下是本篇文章正文內(nèi)容,下面案例可供參考

一、示例

上面示例,下面echarts示例

polar

二、設(shè)計(jì)步驟

1.緯度

幾個(gè)div,設(shè)置圓角

2.經(jīng)度

多條0.5px的邊框,通過旋轉(zhuǎn)實(shí)現(xiàn)

lines: [
        {
          id: 1,
          transform: "translateX(-50%) rotateZ(0deg) scaleX(0.4)",
          borderStyle: "solid",
          borderColor: "#333",
        },
        {
          id: 2,
          transform: "translateX(-50%) rotateZ(45deg) scaleX(0.4)",
          borderStyle: "dashed",
          borderColor: "#91cc75",
        },
        {
          id: 3,
          transform: "translateX(-50%) rotateZ(90deg) scaleX(0.4)",
          borderStyle: "solid",
          borderColor: "#333",
        },
        {
          id: 4,
          transform: "translateX(-50%) rotateZ(135deg) scaleX(0.4)",
          borderStyle: "dashed",
          borderColor: "#91cc75",
        },
      ],

3.衛(wèi)星(點(diǎn))

后臺(tái)的數(shù)據(jù)只有經(jīng)度和緯度。緯度很好做,按照90°的比例進(jìn)行定位。經(jīng)度用到旋轉(zhuǎn),注意不是直接在點(diǎn)上旋轉(zhuǎn),否則只是盒子旋轉(zhuǎn),需要在點(diǎn)外邊套一個(gè)div進(jìn)行旋轉(zhuǎn),如果需要美化,可以使點(diǎn)反方向旋轉(zhuǎn)該角度達(dá)到編號(hào)是一個(gè)正的效果。

三、代碼實(shí)現(xiàn)

代碼是以vue的組件來寫的,satellites就是極坐標(biāo)的數(shù)據(jù)接口。

<template>
  <div class="polar">
    <div class="polar-main">
      <div class="polar-1">
        <div class="polar-2">
          <div class="polar-3">
            <p
              v-for="item in latitudes"
              :key="item.id"
              class="latitude"
              :style="{
                top: item.location.top,
                transform: item.location.transform,
              }"
            >
              {{ item.value }}
            </p>
            <div class="polar-center">
              <div class="satellites">
                <div v-for="item in satellites" :key="item.name">
                  <p
                    v-for="ele in item.distribution"
                    :key="ele.id"
                    class="satellite-box"
                    :style="{
                      transform: rotate(ele.long),
                    }"
                  >
                    <el-tooltip
                      class="item"
                      effect="dark"
                      :content="`經(jīng)度:${ele.long} 緯度:${ele.lati}`"
                      placement="top-start"
                    >
                      <span
                        class="satellite"
                        :style="{
                          backgroundColor: ele.color,
                          top: top(ele.lati),
                          transform: rotate(-1 * ele.long),
                        }"
                        >{{ ele.id }}</span
                      >
                    </el-tooltip>
                  </p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <p
        v-for="item in lines"
        :key="item.id"
        class="line"
        :style="{
          transform: item.transform,
          borderStyle: item.borderStyle,
          borderColor: item.borderColor,
        }"
      ></p>
      <p
        v-for="item in longitudes"
        :key="item.id"
        class="longitude"
        :style="{
          top: item.location.top,
          left: item.location.left,
          transform: item.location.transform,
        }"
      >
        {{ item.value }}
      </p>
    </div>
    <div class="satellite-name"></div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      lines: [
        {
          id: 1,
          transform: "translateX(-50%) rotateZ(0deg) scaleX(0.4)",
          borderStyle: "solid",
          borderColor: "#333",
        },
        {
          id: 2,
          transform: "translateX(-50%) rotateZ(45deg) scaleX(0.4)",
          borderStyle: "dashed",
          borderColor: "#91cc75",
        },
        {
          id: 3,
          transform: "translateX(-50%) rotateZ(90deg) scaleX(0.4)",
          borderStyle: "solid",
          borderColor: "#333",
        },
        {
          id: 4,
          transform: "translateX(-50%) rotateZ(135deg) scaleX(0.4)",
          borderStyle: "dashed",
          borderColor: "#91cc75",
        },
      ],
      longitudes: [
        {
          id: 5,
          value: "90°",
          location: {
            top: "50%",
            left: "100%",
            transform: "translateY(-50%)",
          },
        },
        {
          id: 6,
          value: "180°",
          location: {
            top: "100%",
            left: "50%",

            transform: "translateX(-50%)",
          },
        },
        {
          id: 7,
          value: "270°",
          location: {
            top: "50%",
            left: "0",

            transform: "translateX(-100%) translateY(-50%)",
          },
        },
        {
          id: 8,
          value: "360°",
          location: {
            top: "0",
            left: "50%",
            transform: "translateX(-50%) translateY(-100%)",
          },
        },
      ],
      latitudes: [
        {
          id: 1,
          value: "90°",
          location: {
            top: "50%",
            left: "0",
            transform: "translateY(-50%) translateX(50%)",
          },
        },
        {
          id: 2,
          value: "60°",
          location: {
            top: "0",
            left: "0",
            transform: "translateY(-50%) translateX(50%)",
          },
        },
        {
          id: 3,
          value: "30°",
          location: {
            top: "-50%",
            left: "0",
            transform: "translateY(-50%) translateX(50%)",
          },
        },
      ],
      satellites: [
        {
          name: "Below Mask",
          distribution: [
            {
              id: "10",
              long: 46.397128,
              lati: 56.397128,
              color: "#409eff",
            },
            {
              id: "08",
              long: 76.397128,
              lati: 32.916527,
              color: "#409eff",
            },
          ],
        },
        {
          name: "Unhealthy",
          distribution: [
            {
              id: "25",
              long: 156.397128,
              lati: 62.916527,
              color: "#f56c6c",
            },
            {
              id: "25",
              long: 316.397128,
              lati: 12.916527,
              color: "#f56c6c",
            },
          ],
        },
        {
          name: "Missing",
          distribution: [
            {
              id: "07",
              long: 256.397128,
              lati: 22.916527,
              color: "#118452",
            },
            {
              id: "18",
              long: 56.397128,
              lati: 27.916527,
              color: "#118452",
            },
            {
              id: "12",
              long: 66.397128,
              lati: 27.916527,
              color: "#118452",
            },
            {
              id: "16",
              long: 196.397128,
              lati: 67.916527,
              color: "#118452",
            },
          ],
        },
      ],
    };
  },
  methods: {
    top(lati) {
      return ((90 - lati) / 90) * -90 - 10 + "px";
    },
    rotate(long) {
      let z = (long / 360) * 360;
      return `rotateZ(${z}deg)`;
    },
  },
  //   filters: {},
};
</script>
<style scoped lang='scss'>
$polarPiameter: 180px;
.polar-main {
  width: $polarPiameter;
  height: $polarPiameter;
  position: relative;
  p {
    margin: 0;
  }
  .polar-1 {
    width: $polarPiameter;
    height: $polarPiameter;
    border-style: solid;
    .polar-2 {
      width: $polarPiameter * 2/3;
      height: $polarPiameter * 2/3;
      border-style: dashed;
      .polar-3 {
        width: $polarPiameter/3;
        height: $polarPiameter/3;
        border-style: dashed;
        .polar-center {
          width: 1px;
          height: 1px;
          background-color: #333;
        }
      }
    }
  }
  .line {
    height: $polarPiameter;
    border-right-color: #333;
    border-right-width: 1px;
    border-right-style: solid;
    position: absolute;
    left: 50%;
    cursor: pointer;
  }
  .longitude,
  .latitude {
    height: 14px;
    line-height: 14px;
    font-size: 12px;
    color: #868585;
    position: absolute;
    cursor: pointer;
  }
}
.polar-1,
.polar-2,
.polar-3,
.polar-center {
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  border-color: #91cc75;
  border-width: 1px;
  box-sizing: border-box;
  cursor: pointer;
}
.polar-1:hover {
  border-width: 2px;
}
.polar-2:hover{
  border-width: 2px;
}
.satellite-box {
  position: absolute;
  width: 1px;
  height: 1px;
  border-radius: 50%;
  background-color: transparent;
  .satellite {
    position: absolute;
    left: -10px;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    font-size: 14px;
    color: #fff;
    cursor: pointer;
    z-index: 999;
    opacity: 0.6;
    transition: 0.6s;
  }
  .satellite:hover {
    background-color: #333 !important;
  }
}
</style>

總結(jié)

示例圖:

在這里插入圖片描述

到此這篇關(guān)于CSS極坐標(biāo)的實(shí)例代碼的文章就介紹到這了,更多相關(guān)CSS極坐標(biāo)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

  • HTML 表格詳解(簡單易懂較詳細(xì))

    HTML表格用于在網(wǎng)頁上展示數(shù)據(jù),通過標(biāo)簽及其相關(guān)標(biāo)簽來創(chuàng)建,表格由行和列組成,每一行包含一個(gè)或多個(gè)單元格,單元格可以包含文本、圖像、鏈接等元素,本文將詳細(xì)介紹HTML表格
    2025-03-12
  • 禁止HTML頁面滾動(dòng)的操作方法

    本文介紹了三種禁止HTML頁面滾動(dòng)的方法:通過CSS的overflow屬性、使用JavaScript的滾動(dòng)事件監(jiān)聽器以及使用CSS的position:fixed屬性,每種方法都有其適用場景和優(yōu)缺點(diǎn),感興
    2025-02-24
  • 使用HTML和CSS實(shí)現(xiàn)文字鏤空效果的代碼示例

    在 Web 開發(fā)中,文本的視覺效果是提升用戶體驗(yàn)的重要因素之一,通過 CSS 技巧,我們可以創(chuàng)造出許多獨(dú)特的效果,例如文字鏤空效果,本文將帶你一步一步實(shí)現(xiàn)一個(gè)簡單的文字鏤空
    2024-11-17
  • Html去除a標(biāo)簽的默認(rèn)樣式的操作代碼

    在Html中,a標(biāo)簽?zāi)J(rèn)的超鏈接樣式是藍(lán)色字體配下劃線,這可能不滿足所有設(shè)計(jì)需求,如需去除這些默認(rèn)樣式,可以通過CSS來實(shí)現(xiàn),本文給大家介紹Html去除a標(biāo)簽的默認(rèn)樣式的操作代碼
    2024-09-25
  • HTML文本域如何設(shè)置為禁止用戶手動(dòng)拖動(dòng)

    在HTML中,可以通過設(shè)置CSS的resize屬性為none,來禁止用戶手動(dòng)拖動(dòng)文本域(textarea)的大小,這種方法簡單有效,適用于大多數(shù)現(xiàn)代瀏覽器,但需要在老舊瀏覽器中進(jìn)行測試以確保
    2024-09-25
  • 如何通過HTML/CSS 實(shí)現(xiàn)各類進(jìn)度條的功能

    本文詳細(xì)介紹了如何利用HTML和CSS實(shí)現(xiàn)多種風(fēng)格的進(jìn)度條,包括基礎(chǔ)的水平進(jìn)度條、環(huán)形進(jìn)度條以及球形進(jìn)度條等,還探討了如何通過動(dòng)畫增強(qiáng)視覺效果,內(nèi)容涵蓋了使用HTML原生標(biāo)簽
    2024-09-19
  • HTML中Canvas關(guān)鍵知識(shí)點(diǎn)總結(jié)

    Canvas 提供了一套強(qiáng)大的 2D 繪圖 API,適用于各種圖形繪制、圖像處理和動(dòng)畫制作,可以幫助你創(chuàng)建復(fù)雜且高效的網(wǎng)頁圖形應(yīng)用,這篇文章主要介紹了HTML中Canvas關(guān)鍵知識(shí)點(diǎn)總結(jié)
    2024-06-03
  • html table+css實(shí)現(xiàn)可編輯表格的示例代碼

    本文主要介紹了html table+css實(shí)現(xiàn)可編輯表格的示例代碼,主要使用HTML5的contenteditable屬性,文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)
    2024-03-06
  • HTML中使用Flex布局實(shí)現(xiàn)雙行夾批效果

    本文主要介紹了HTML中使用Flex布局實(shí)現(xiàn)雙行夾批效果,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)
    2024-02-22
  • HTML+CSS實(shí)現(xiàn)炫酷登錄切換的項(xiàng)目實(shí)踐

    在網(wǎng)站開發(fā)中,登錄頁面是必不可少的一部分,本文就來介紹一下HTML+CSS實(shí)現(xiàn)登錄切換,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需
    2024-02-02

最新評(píng)論