日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

前端每日实战:34# 视频演示如何用纯 CSS 创作在文本前后穿梭的边框

發布時間:2025/3/8 HTML 13 豆豆
生活随笔 收集整理的這篇文章主要介紹了 前端每日实战:34# 视频演示如何用纯 CSS 创作在文本前后穿梭的边框 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

效果預覽

按下右側的“點擊預覽”按鈕可以在當前頁面預覽,點擊鏈接可以全屏預覽。

https://codepen.io/comehope/pen/qYepNv

可交互視頻教程

此視頻是可以交互的,你可以隨時暫停視頻,編輯視頻中的代碼。

請用 chrome, safari, edge 打開觀看。

https://scrimba.com/p/pEgDAM/cQ73Vt8

源代碼下載

每日前端實戰系列的全部源代碼請從 github 下載:

https://github.com/comehope/front-end-daily-challenges

代碼解讀

定義 dom,容器中包含文本:

<div class="warning">ERROR 404</div>

居中顯示:

body {margin: 0;height: 100vh;display: flex;align-items: center;justify-content: center;background-color: rgb(20%, 20%, 20%); }

定義文字樣式:

.warning {color: whitesmoke;font-size: 100px;font-family: sans-serif;font-weight: bold; }

用偽元素定義邊框尺寸:

.warning {position: relative;padding: 0.6em 0.4em; }.warning::before, .warning::after {content: '';position: absolute;top: 0;left: 0;width: 100%;height: 100%;border: 0.2em solid;box-sizing: border-box; }

把邊框分為兩部分,拼在一起:

.warning::before, .warning::after {border: 0.2em solid transparent;color: orangered; }.warning::before {border-top-color: currentColor;border-right-color: currentColor; }.warning::after {border-bottom-color: currentColor;border-left-color: currentColor; }

把上邊框和右邊框下沉一層:

.warning::before {z-index: -1; }

為下邊框和在邊框加上陰影:

.warning::after {box-shadow: 0.3em 0.3em 0.3em rgba(20%, 20%, 20%, 0.8); }

最后,讓邊框轉起來:

.warning::before, .warning::after {animation: rotating 10s infinite; }@keyframes rotating {to {transform: rotate(360deg);} }

大功告成!

總結

以上是生活随笔為你收集整理的前端每日实战:34# 视频演示如何用纯 CSS 创作在文本前后穿梭的边框的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。