用vue實現彩虹

在template添加一個div,具體代碼如下:

<template>

    <div class="head"></div>

</template>

用css對div的內容進行修飾。首先創建一個背景爲粉紅色,半徑爲100px的圓。

<style>
  .head{
    width: 200px;
    height: 200px;
    background: pink;
    border-radius: 50%;
  }
</style>

然後在對圓中內容進行更改。

<style>
  .head{
    width: 200px;
    height: 200px;
    background: pink;
    border-radius: 50%;
    box-shadow:
    0 0 0 5px inset red,
    0 0 0 10px inset orange,
    0 0 0 15px inset yellow,
    0 0 0 20px inset lime,
    0 0 0 25px inset aqua,
    0 0 0 30px inset blue,
    0 0 0 35px inset magenta;
    clip-path:polygon(0 0,100% 0,100% 50%,0 50%);
  }
</style>

 polygon

1. 值爲多個座標點組成,根據多個座標形成一個半圓。

去掉背景色內容。

<style>
  .head{
    width: 200px;
    height: 200px;
    border-radius: 50%;
    box-shadow:
    0 0 0 5px inset red,
    0 0 0 10px inset orange,
    0 0 0 15px inset yellow,
    0 0 0 20px inset lime,
    0 0 0 25px inset aqua,
    0 0 0 30px inset blue,
    0 0 0 35px inset magenta;
    clip-path:polygon(0 0,100% 0,100% 50%,0 50%);
  }
</style>

最終實現效果:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章