react + less制作一個(gè)箭頭步驟條

效果
image.png
index.tsx
import styles from "./index.module.less";
interface Props {
  stepList: string[],
  activeIndex: number
}
export default function Index(props: Props) {
  const {
    stepList = ['基本信息', '數(shù)據(jù)來(lái)源配置', '數(shù)據(jù)結(jié)構(gòu)配置', '關(guān)聯(lián)元數(shù)據(jù)配置'],
    activeIndex = 1
  } = props

  return <div className={styles.stepBox}>
    {stepList.map((item, index) => <div className={styles.stepBar} key={index} data-active={activeIndex >= index ? true : false}>
      {item}
    </div>)}
  </div>
}
less
.stepBox {
  display: flex;
}

.stepBar {
  position: relative;
  width: 160px;
  height: 40px;
  line-height: 40px;
  background: #F7F8FA;
  margin: 0px 2px;
  color: #575C66;
  font-size: 14px;
  text-align: center;

  &:first-child::after {
    display: none;
  }

  &:last-child::before {
    display: none;
  }

  &[data-active='true'] {
    background: #9434DF;
    color: #fff;
    font-weight: 500;

    &::before {
      border-color: transparent transparent transparent #9434DF;
    }
  }
}

.stepBar::before {
  content: " ";
  width: 0;
  height: 0;
  border: solid;
  border-color: transparent transparent transparent #F7F8FA;
  border-top-width: 20px;
  border-right-width: 20px;
  border-bottom-width: 20px;
  border-left-width: 14px;
  position: absolute;
  right: -33px;
  top: 0px;
  z-index: 1;
}

.stepBar::after {
  content: " ";
  width: 0;
  height: 0;
  border: solid;
  border-color: transparent transparent transparent #fff;
  border-top-width: 20px;
  border-right-width: 20px;
  border-bottom-width: 20px;
  border-left-width: 14px;
  position: absolute;
  left: 0px;
  top: 0px;
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • """1.個(gè)性化消息: 將用戶的姓名存到一個(gè)變量中,并向該用戶顯示一條消息。顯示的消息應(yīng)非常簡(jiǎn)單,如“Hello ...
    她即我命閱讀 5,273評(píng)論 0 6
  • 為了讓我有一個(gè)更快速、更精彩、更輝煌的成長(zhǎng),我將開(kāi)始這段刻骨銘心的自我蛻變之旅!從今天開(kāi)始,我將每天堅(jiān)持閱...
    李薇帆閱讀 2,248評(píng)論 1 4
  • 似乎最近一直都在路上,每次出來(lái)走的時(shí)候感受都會(huì)很不一樣。 1、感恩一直遇到好心人,很幸運(yùn)。在路上總是...
    時(shí)間里的花Lily閱讀 1,752評(píng)論 1 3
  • 1、expected an indented block 冒號(hào)后面是要寫(xiě)上一定的內(nèi)容的(新手容易遺忘這一點(diǎn)); 縮...
    庵下桃花仙閱讀 1,098評(píng)論 1 2
  • 一、工具箱(多種工具共用一個(gè)快捷鍵的可同時(shí)按【Shift】加此快捷鍵選取)矩形、橢圓選框工具 【M】移動(dòng)工具 【V...
    墨雅丫閱讀 1,589評(píng)論 0 0

友情鏈接更多精彩內(nèi)容