iT邦幫忙

2021 iThome 鐵人賽

DAY 27
0
Modern Web

33歲轉職者的前端筆記系列 第 27

33歲轉職者的前端筆記 DAY 27 CSS 三角形、三角形折角、轉 45 度漸層色

CSS 三角形作法

https://ithelp.ithome.com.tw/upload/images/20210926/20120789lIAlEcjDcc.png

語法

HTML

<div class="box"></div>

CSS

.box {
  width: 0px;
  height: 0px;
  border-right: 40px solid transparent;
  border-bottom: 40px solid blue;
  border-left: 40px solid transparent;
}

CSS 折角三角形做法

https://ithelp.ithome.com.tw/upload/images/20210926/20120789mt9fdzI1uZ.png

HTML

<div class="tab">
  三角形折角
  <div class="arrow"></div>
</div>

CSS

.tab {
  width: 100px;
  height: 30px;
  line-height: 30px;
  position: relative;
  background-color: #fa0;
}

.arrow {
  width: 0;
  height: 0;
  position: absolute;
  border-top: 5px solid #850;
  border-left: 10px solid transparent;
}

CSS 轉 45 度漸層色

https://ithelp.ithome.com.tw/upload/images/20210926/20120789bfSYLrLOHk.png

HTML

<div class="box"></div>

CSS

.box {
  width: 300px;
  height: 300px;
  background-color: #f00;
  background-image: linear-gradient(45deg, #f00 0%, #ff0 50%, #0f0 100%);
}

background-image: linear-gradient(角度, 色標, 色標);

0 度是由下往上,角度是順時針轉


上一篇
[鼠年全馬鐵人挑戰] Week26 - jQuery 事件處理
下一篇
33歲轉職者的前端筆記 DAY 28 CSS 選取器類別筆記
系列文
33歲轉職者的前端筆記30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言