帶給大家用純CSS3實現全螢幕背景切換焦點圖效果,不參夾JS的程式碼,簡單易懂還好用,需要的朋友可以直接搬運。下面我們來看看
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>自适应全屏焦点图切换CSS3特效代码</title> <meta name="keywords" content="自适应,全屏,焦点图,切换,CSS3,特效代码" /> <meta name="description" content="自适应全屏焦点图切换CSS3特效代码,纯CSS实现不用任何js代码。" /> <style> *{margin:0;padding:0;list-style: none;} img.bg{min-width: 1024px;min-height: 100%;width: 100%;height: auto!important;height: 100%;position: fixed;top: 0;left: 0;z-index: 1;} @media screen and (max-width: 1024px) { img.bg{ left: 50%; margin-left: -512px; } } .slider{ position: absolute; width: 100%; text-align: center; z-index: 999; bottom: 100px; } .slider li{ display: inline-block; width: 170px; height: 130px; margin-right: 15px; } .slider a{ display: inline-block; width: 170px; padding-top:70px; padding-bottom:20px; position: relative; cursor: pointer; border:2px solid #fff; border-radius: 5px; vertical-align: top;/*设置元素的垂直对齐方式。*/ color: #FFFFFF; text-decoration: none; font-size: 22px; font-family: "楷体"; text-shadow: -1px -1px 1px rgba(0,0,0,0.8), -2px -2px 1px rgba(0, 0, 0, 0.3), -3px -3px 1px rgba(0, 0, 0, 0.3); } .slider li:nth-of-type(1) a{ background-color: #02646e; } .slider li:nth-of-type(2) a{ background-color: #eb0837; } .slider li:nth-of-type(3) a { background-color: #67b374; } .slider li:nth-of-type(4) a { background-color: #e6674a; } .slider li:nth-of-type(5) a { background-color: #e61061; } .slider a::after{/*:after 选择器在被选元素的内容后面插入内容。*/ content: ""; display: block; height: 120px; width: 120px; border:5px solid #fff; border-radius: 50%; position: absolute; left: 50%; margin-left: -60px; z-index: 9999; top: -80px; } .slider li:nth-of-type(1) a::after { /*:nth-of-type(n) 选择器匹配属于父元素的特定类型的第 N 个子元素的每个元素.*/ background: url(img/sbg1.jpg) no-repeat center; } .slider li:nth-of-type(2) a::after { background: url(img/sbg2.jpg) no-repeat center; } .slider li:nth-of-type(3) a::after { background: url(img/sbg3.jpg) no-repeat center; } .slider li:nth-of-type(4) a::after { background: url(img/sbg4.jpg) no-repeat center; } .slider li:nth-of-type(5) a::after { background: url(img/sbg5.jpg) no-repeat center; } .slider a::before{ content: ""; display: block; height: 120px; width: 120px; border:5px solid #fff; border-radius: 50%; position: absolute; left: 50%; margin-left: -60px; z-index: 99999; top: -80px; background:rgba(0,0,0,0.3); } .slider a:hover::before{ opacity: 0; } @-webkit-keyframes 'slideLeft'{ 0%{ left:-500px; } 100%{ left:0; } } .slideLeft:target{ /*:target 选择器可用于选取当前活动的目标元素*/ z-index: 100; animation: slideLeft 1s 1; -webkit-animation: slideLeft 1s 1; } @-webkit-keyframes 'slideBottom'{ 0%{ top:350px; } 100%{ top:0; } } .slideBottom:target{ /*:target 选择器可用于选取当前活动的目标元素*/ z-index: 100; animation: slideBottom 1s 1; -webkit-animation: slideBottom 1s 1; } @-webkit-keyframes 'zoomIn' { 0% { -webkit-transform: scale(0.1); } 100% { -webkit-transform: none; } } .zoomIn:target { z-index: 100; -webkit-animation: zoomIn 1s 1; animation: zoomIn 1s 1; } /* Zoom Out */ @-webkit-keyframes 'zoomOut' { 0% { -webkit-transform: scale(2); } 100% { -webkit-transform: none; } } .zoomOut:target { z-index: 100; -webkit-animation: zoomOut 1s 1; animation: zoomOut 1s 1; } /* Rotate */ @-webkit-keyframes 'rotate' { 0% { -webkit-transform: rotate(-360deg) scale(0.1); } 100% { -webkit-transform: none; } } .rotate:target { z-index: 100; -webkit-animation: rotate 1s 1; animation: rotate 1s 1; } @-webkit-keyframes 'notTarget' { 0% { z-index: 75; } 100% { z-index: 75; } } .bg:not(:target) { -webkit-animation: notTarget 1s 1; animation: notTarget 1s 1 } .page { text-align:left; } </style> </head> <body> <div> <ul> <li><a href="#bg1">Hipster Fashion Haircut</a></li> <li><a href="#bg2">Cloud Computing Services & Consulting</a></li> <li><a href="#bg3">My haire is sooo fantastic!</a></li> <li><a href="#bg4">Eat healthy & excersice!</a></li> <li><a href="#bg5">Lips so kissable I could die ...</a></li> </ul> </div> <img class="bg slideLeft lazy" src="/static/imghwm/default1.png" data-src="img/bg1.jpg" id="bg1" / alt="CSS3自適應全螢幕焦點圖切換的特效怎麼做" > <img class="bg slideBottom lazy" src="/static/imghwm/default1.png" data-src="img/bg2.jpg" id="bg2" / alt="CSS3自適應全螢幕焦點圖切換的特效怎麼做" > <img class="bg zoomIn lazy" src="/static/imghwm/default1.png" data-src="img/bg3.jpg" id="bg3" / alt="CSS3自適應全螢幕焦點圖切換的特效怎麼做" > <img class="bg zoomOut lazy" src="/static/imghwm/default1.png" data-src="img/bg4.jpg" id="bg4" / alt="CSS3自適應全螢幕焦點圖切換的特效怎麼做" > <img class="bg rotate lazy" src="/static/imghwm/default1.png" data-src="img/bg5.jpg" id="bg5" / alt="CSS3自適應全螢幕焦點圖切換的特效怎麼做" > </body> </html>
自適應全螢幕焦點圖切換的特效就這麼多了。更多精彩請關注php中文網其它相關文章!
相關閱讀:
以上是CSS3自適應全螢幕焦點圖切換的特效怎麼做的詳細內容。更多資訊請關注PHP中文網其他相關文章!
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

React生態系統為我們提供了許多庫,所有庫都集中在拖放的相互作用上。我們有反應,反應,可愛dnd,

我可以說我經常使用背景折疊。 IT Wager IT幾乎從未在日常CSS工作中使用。但是在斯特凡·朱迪斯(Stefan Judis)的帖子中,我想起了它,

使用RequestAnimationFrame進行動畫化應該很容易,但是如果您還沒有徹底閱讀React的文檔,那麼您可能會遇到一些事情

聽著,我不是GraphQL專家,但我確實喜歡與之合作。作為前端開發人員,它向我曝光數據的方式非常酷。它就像一個菜單


熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 個月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
1 個月前By尊渡假赌尊渡假赌尊渡假赌
刺客信條陰影:貝殼謎語解決方案
3 週前ByDDD
Windows 11 KB5054979中的新功能以及如何解決更新問題
2 週前ByDDD
威爾R.E.P.O.有交叉遊戲嗎?
1 個月前By尊渡假赌尊渡假赌尊渡假赌

熱工具

Dreamweaver CS6
視覺化網頁開發工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器

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

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

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