我迫不及待地想要一些「空閒」時間,這樣我就可以為我的專案添加樣式。一點點互動性可以為頁面增添活力。
你想要一隻漂浮的貓嗎?沒問題。我使用 AI 製作了一張貓的圖像,並在 Illustrator 中「手動」提取了背景,為我的 .png 圖像獲得了漂亮的剪切效果。嘭。貓。
讓他移動一點,這樣他看起來就像是漂浮的。我最喜歡的 CSS 動畫之一是軌道。它真的很有用,你可以用它做很多事情。
貓
在視圖中,我將我的貓的圖像帶入並為其分配“貓”類
現在,在我的 css 檔案中,我建立了「cat」的樣式。在 cat 中,我們將我們的動畫稱為“軌道”,如下所示。
.cat { animation: orbit 3s infinite linear; } @keyframes orbit { from { transform: rotate(0deg) translateX(15px) rotate(0deg); } to { transform: rotate(360deg) translateX(15px) rotate(-360deg); } }
在這裡您可以看到,我們“從 0 度角度開始旋轉貓”,距離 x 原點 15px,從 0 度開始。
貓咪在 15px 處繞了一整圈 360 度,一直繞了一圈。 -360 的第二次旋轉抵消了第一次旋轉,使貓保持直立。如果你只看動畫就更容易了。 XD。
我們只是稍微移動了他,因為我們不希望他在頁面上飛來飛去。足以令人興奮。
往左一點,
向右一點。
魔法!
立方體
我之前學過如何用 css 創建立方體。雖然這很好,但我今天有了一個瘋狂的想法,以動態的方式重新使用立方體。我想用即時數據填充立方體表面。就像說,接下來的一些即將發生的事件。就像在登陸頁面上發現一件有趣的事情一樣。為什麼不呢。這很令人興奮。
因此,我在視圖中建立了骨架。我們的立方體畢竟需要一個家。
我有一些單選按鈕,以便使用者可以與多維資料集互動。
每個單選按鈕都會顯示不同的立方體。
我循環添加我想要在每個面上顯示的資訊:
<div> <hr> <p>Handling the css is a bit of a dance. Especially with viewports and what not. This is not the answer for mobile but it will work and be functional on a bigger screen, LOL. I'm just gonna leave this here for you. Open to suggestions for handling a small screen size. <br> </p> <hr> <p><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/173429456116557.jpg?x-oss-process=image/resize,p_40" class="lazy" alt="Floating Cats and Cubes"><br> <br><br> </p> <pre class="brush:php;toolbar:false"> /*=========== rotating cube ==============*/ .cube-container { width: 30vw; height: 40vh; text-align: center; perspective: 100em; } .cube { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition-duration: 2s; border: 5px solid transparent; margin-top:100px; display: block; } .cube-side { position: absolute; width: 300px; height: 300px; background-color: rgb(64, 0, 148); border: 1px solid white; background-position: center; background-size: cover; border: 4px solid lime; } .cube-side:nth-child(1){ transform: rotateY(0deg) translateZ(10em); } .cube-side:nth-child(2){ transform: rotateY(90deg) translateZ(10em); } .cube-side:nth-child(3){ transform: rotateY(180deg) translateZ(10em); } .cube-side:nth-child(4){ transform: rotateY(-90deg) translateZ(10em); } .cube-side:nth-child(5){ transform: rotateX(90deg) translateZ(9.75em); border-top: 8px solid lime; border-bottom: 8px solid lime; } .cube-side:nth-child(6){ transform: rotateX(-90deg) translateZ(9.3em); border-top: 8px solid lime; border-bottom: 8px solid lime; } /* cube radio buttons */ .radio-button { transform: translateX(-50px); } .radio-button:checked ~ .cube{ transition-duration: 3s; transition-timing-function: cubic-bezier(0.19. 1, 0.22, 1); } .radio-button:nth-child(1):checked ~ .cube { transform: rotateX(-15deg) rotateY(20deg); } .radio-button:nth-child(2):checked ~ .cube { transform: rotateX(-15deg) rotateY(180deg); } .radio-button:nth-child(3):checked ~ .cube { transform: rotateX(-15deg) rotateY(90deg); } .radio-button:nth-child(4):checked ~ .cube { transform: rotateX(-15deg) rotateY(-90deg); } .radio-button:nth-child(5):checked ~ .cube { transform: rotateX(-105deg) rotateY(0deg); } .radio-button:nth-child(6):checked ~ .cube { transform: rotateX(75deg) rotateY(0deg); }
每個按鈕和側面都是單獨處理的。我很想看到一個更優雅的解決方案(如果存在)。
我真的很興奮它成功了。
感謝您的瀏覽!
以上是漂浮的貓和立方體的詳細內容。更多資訊請關注PHP中文網其他相關文章!

@keyframesandCSSTransitionsdifferincomplexity:@keyframesallowsfordetailedanimationsequences,whileCSSTransitionshandlesimplestatechanges.UseCSSTransitionsforhovereffectslikebuttoncolorchanges,and@keyframesforintricateanimationslikerotatingspinners.

我知道,我知道:有大量的內容管理系統選項可用,而我進行了幾個測試,但實際上沒有一個是一個,y&#039;知道嗎?怪異的定價模型,艱難的自定義,有些甚至最終成為整個&

鏈接CSS文件到HTML可以通過在HTML的部分使用元素實現。 1)使用標籤鏈接本地CSS文件。 2)多個CSS文件可通過添加多個標籤實現。 3)外部CSS文件使用絕對URL鏈接,如。 4)確保正確使用文件路徑和CSS文件加載順序,優化性能可使用CSS預處理器合併文件。

選擇Flexbox還是Grid取決於佈局需求:1)Flexbox適用於一維佈局,如導航欄;2)Grid適合二維佈局,如雜誌式佈局。兩者在項目中可結合使用,提升佈局效果。

包含CSS文件的最佳方法是使用標籤在HTML的部分引入外部CSS文件。 1.使用標籤引入外部CSS文件,如。 2.對於小型調整,可以使用內聯CSS,但應謹慎使用。 3.大型項目可使用CSS預處理器如Sass或Less,通過@import導入其他CSS文件。 4.為了性能,應合併CSS文件並使用CDN,同時使用工具如CSSNano進行壓縮。

是的,youshouldlearnbothflexboxandgrid.1)flexboxisidealforone-demensional,flexiblelayoutslikenavigationmenus.2)gridexcelstcelsintwo-dimensional,confffferDesignssignssuchasmagagazineLayouts.3)blosebothenHancesSunHanceSlineHancesLayOutflexibilitibilitibilitibilitibilityAnderibilitibilityAndresponScormentilial anderingStruction

重構自己的代碼看起來是什麼樣的?約翰·瑞亞(John Rhea)挑選了他寫的一個舊的CSS動畫,並介紹了優化它的思維過程。

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

禪工作室 13.0.1
強大的PHP整合開發環境

SublimeText3漢化版
中文版,非常好用

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中