久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      css怎么實(shí)現(xiàn)三角形

      實(shí)現(xiàn)方法:1、利用高寬為零的容器和透明的border;2、利用線性漸變linear-gradient;3、使用“transform:rotate”配合“overflow:hidden”;4、利用“&#9660”、“&#9650”等字符繪制。

      css怎么實(shí)現(xiàn)三角形

      本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。

      使用 border 繪制三角形

      使用 border 實(shí)現(xiàn)三角形應(yīng)該是大部分人都掌握的,也是各種面經(jīng)中經(jīng)常出現(xiàn)的,利用了高寬為零的容器及透明的 border 實(shí)現(xiàn)。

      簡單的代碼如下:

      <div class='normal'></div>
      html, body {   width: 100%;   height: 100%;   display: flex; }  div {   width: 0px;   height: 0px;   margin: auto; }  .normal {   border-top: 50px solid yellowgreen;   border-bottom: 50px solid deeppink;   border-left: 50px solid bisque;   border-right: 50px solid chocolate; }

      高寬為零的容器,設(shè)置不同顏色的 border:

      css怎么實(shí)現(xiàn)三角形

      這樣,讓任何三邊的邊框的顏色為 transparent,則非常容易得到各種角度的三角形:

      <div class='top'></div> <div class='bottom'></div> <div class='left'></div> <div class='right'></div>
      .top {   border: 50px solid transparent;   border-bottom: 50px solid deeppink; }  .left {   border: 50px solid transparent;   border-right: 50px solid deeppink; }  .bottom {   border: 50px solid transparent;   border-top: 50px solid deeppink; }  .right {   border: 50px solid transparent;   border-bottom: 50px solid deeppink; }

      css怎么實(shí)現(xiàn)三角形

      使用 linear-gradient 繪制三角形

      接著,我們使用線性漸變 linear-gradient 實(shí)現(xiàn)三角形。

      它的原理也非常簡單,我們實(shí)現(xiàn)一個(gè) 45° 的漸變:

      div {   width: 100px;   height: 100px;   background: linear-gradient(45deg, deeppink, yellowgreen); }

      css怎么實(shí)現(xiàn)三角形

      讓它的顏色從漸變色變?yōu)閮煞N固定的顏色:

      div {   width: 100px;   height: 100px;   background: linear-gradient(45deg, deeppink, deeppink 50%, yellowgreen 50%, yellowgreen 100%); }

      css怎么實(shí)現(xiàn)三角形

      再讓其中一個(gè)顏色透明即可:

      div {   background: linear-gradient(45deg, deeppink, deeppink 50%, transparent 50%, transparent 100%); }

      css怎么實(shí)現(xiàn)三角形

      transform: rotate 配合 overflow: hidden 繪制三角形

      這種方法還是比較常規(guī)的,使用 transform: rotate 配合 overflow: hidden。一看就懂,一學(xué)就會(huì),簡單的動(dòng)畫示意圖如下:

      css怎么實(shí)現(xiàn)三角形

      設(shè)置圖形的旋轉(zhuǎn)中心在左下角 left bottom,進(jìn)行旋轉(zhuǎn),配合 overflow: hidden。

      完整的代碼:

      <div class="demo"></div> <div class="demo-opacity"></div> <div class="triangle"></div>
      html, body {     width: 100%;     height: 100%;     display: flex; }  div {     width: 141px;     height: 100px;     margin: auto; }  .demo-opacity {     overflow: hidden; }  .demo, .demo-opacity {     position: relative;     border: 1px solid #000;     background: unset;          &::before {         content: "";         position: absolute;         top: 0;         left: 0;         right: 0;         bottom: 0;         animation: conicmove 3s infinite linear;         background: deeppink;         transform-origin: left bottom;         z-index: -1;     } }  .triangle {     position: relative;     background: unset;     overflow: hidden;          &::before {         content: "";         position: absolute;         top: 0;         left: 0;         right: 0;         bottom: 0;         background: deeppink;         transform-origin: left bottom;         transform: rotate(45deg);         z-index: -1;     } }  @keyframes conicmove {     100% {         transform: rotate(45deg);     } }

      利用字符繪制三角形

      OK,最后一種,有些獨(dú)特,就是使用字符表示三角形。

      下面列出一些三角形形狀的字符的十進(jìn)制 Unicode 表示碼。

      ? : &#9668;  ? : &#9658;  ▼ : &#9660;  ▲ : &#9650; ⊿ : &#8895; △ : &#9651;

      譬如,我們使用 &#9660; 實(shí)現(xiàn)一個(gè)三角形 ▼,代碼如下:

      <div class="normal">&#9660; </div>
      div {     font-size: 100px;     color: deeppink; }

      效果還是不錯(cuò)的:

      css怎么實(shí)現(xiàn)三角形

      (學(xué)習(xí)視頻分享:css視頻教程)

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)