【CSS】絲滑邊框線條動(dòng)畫(huà)

用純css實(shí)現(xiàn)絲滑邊框線條動(dòng)畫(huà)

2024-06-06 10-48-47.2024-06-06 10_49_19.gif
// react component render
<div className="w-full h-screen flex items-center justify-center">
      <div
        className={classNames(
          "relative mx-auto w-[300px] h-[200px] p-[1px] bg-[#04071D]",
          "rounded-xl",
          "overflow-hidden",
        )}
      >
        <div
          className={classNames(
            "absolute inset-0 w-[80px] h-[80px] rounded-xl",
            "animate-moveAround translate-x-[-40px] translate-y-[-40px]",
            "bg-[radial-gradient(#CBACF9_40%,transparent_60%)] opacity-80",
          )}
        />
        <div
          className={classNames(
            "relative w-full h-full",
            "bg-slate-900/[0.] backdrop-blur-xl",
            "border-slate-800 border-[0.5px] rounded-xl",
          )}
        />
      </div>
    </div>
export default {
  content: ["./src/**/*.{jsx,tsx,js,ts}"],
  theme: {
    extend: ...,  
    animation: {    
      moveAround: "moveAround 10s linear infinite",
    },
    keyframes: {   
      moveAround: {
        "0% 100%": {
          top: 0,
          left: 40,
        },
        "27.2%": {
          top: 0,
          left: "calc(100%-40px)",
        },
        "30.23%": {
          top: 40,
          left: "calc(100%)",
        },
        "46.96%": {
          top: "calc(100%-40px)",
          left: "calc(100%)",
        },
        "50%": {
          top: "calc(100%)",
          left: "calc(100%-40px)",
        },
        "77.19%": {
          top: "calc(100%)",
          left: 40,
        },
        "80.23%": {
          top: "calc(100%-40px)",
          left: 0,
        },
        "96.96%": {
          top: 40,
          left: 0,
        },
      },
    },
  },
  plugins: ...,
};
?著作權(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)容

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