Hello!小夥伴!
首先很是感謝您閱讀海轟的文章,假若文中有錯誤的地方,歡迎您指出~
哈哈 自我介紹一下
暱稱:海轟
標籤:程序猿一隻|C++選手|學生
簡介:因C語言結識編程,隨後轉入計算機專業,有幸拿過國獎、省獎等,已保研。目前正在學習C++/Linux(真的真的太難了~)
學習經驗:紮實基礎 + 多作筆記 + 多敲代碼 + 多思考 + 學好英語!
平常分享:微信公衆號【海轟Pro】記錄生活、學習點滴,分享一些源代碼或者學習資料,歡迎關注~css
這裏用span元素表明外層白色圓圈html
兩個紅色小球分別用span的兩個僞類::before和::after表明編程
根據效果圖,能夠大概得出思路微信
HTML學習
<!DOCTYPE html> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> <title>Document</title> </head> <body> <section><span></span></section> </body> </html>
CSSflex
html,body{ margin: 0; height: 100%; } body{ display: flex; justify-content: center; align-items: center; background: #263238; } section { width: 650px; height: 300px; padding: 10px; position: relative; display: flex; align-items: center; justify-content: center; /* 紅色邊框僅做提示 */ border: 2px solid red; } span{ width : 96px; height: 96px; border: 10px solid white; border-radius: 50%; display: flex; align-items: center; justify-content: center; position: relative; animation: rotation 2s linear infinite; } span::before{ position: absolute; content: ''; top: 15px; left: 15px; width: 20px; height: 20px; background: red; border-radius: 50%; } span::after{ position: absolute; content: ''; bottom: 15px; right: 15px; width: 20px; height: 20px; background: red; border-radius: 50%; } @keyframes rotation { 0% { transform: rotate(0deg) } 100% { transform: rotate(360deg) } }
將span元素設置爲動畫
width : 96px; height: 96px; border: 10px solid #fff;
效果圖以下
ui
span::before和span::after設置spa
/* before的設置*/ position: absolute; content: ''; top: 0; left: 0; width: 20px; height: 20px; background: red; /*after的設置*/ position: absolute; content: ''; bottom: 0; right: 0; width: 20px; height: 20px; background: red;
效果圖以下3d
稍微向正方形中心移動下::before和::after
/* before的設置*/ top: 15px; left: 15px; /*after的設置*/ bottom: 15px; right: 15px;
效果圖以下
對span、span::before、span::after設置圓角
border-radius: 50%;
效果圖以下
爲span添加動畫
animation: rotation 1s linear infinite;
/*動畫實現*/ @keyframes rotation { 0% { transform: rotate(0deg) } 100% { transform: rotate(360deg) }
效果圖以下
學習來源:
文章僅做爲學習筆記,記錄從0到1的一個過程。但願對您有所幫助,若有錯誤歡迎小夥伴指正~
我是海轟ଘ(੭ˊᵕˋ)੭,若是您以爲寫得能夠的話,請點個贊吧
寫做不易,「點贊」+「收藏」+「轉發」
謝謝支持❤️