搜尋
首頁web前端css教學CSS3自適應全螢幕焦點圖切換的特效怎麼做

帶給大家用純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 &#39;slideLeft&#39;{
                                     0%{
                                               left:-500px;
                                     }
                                     100%{
                                               left:0;
                                     }
                            }
                            .slideLeft:target{
                                     /*:target 选择器可用于选取当前活动的目标元素*/
                                     z-index: 100;
                                     animation: slideLeft 1s 1;
                                     -webkit-animation: slideLeft 1s 1;
                            }
                            @-webkit-keyframes &#39;slideBottom&#39;{
                                     0%{
                                               top:350px;
                                     }
                                     100%{
                                               top:0;
                                     }
                            }
                            .slideBottom:target{
                                     /*:target 选择器可用于选取当前活动的目标元素*/
                                     z-index: 100;
                                     animation: slideBottom 1s 1;
                                     -webkit-animation: slideBottom 1s 1;
                            }
                            @-webkit-keyframes &#39;zoomIn&#39; {
                             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 &#39;zoomOut&#39; {
                             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 &#39;rotate&#39; {
                             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 &#39;notTarget&#39; {
                                      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有哪些新增的背景屬性

怎麼用CSS3媒體查詢

css3的彈性盒怎麼做來

以上是CSS3自適應全螢幕焦點圖切換的特效怎麼做的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
css怎么隐藏元素但不占空间css怎么隐藏元素但不占空间Jun 01, 2022 pm 07:15 PM

两种方法:1、利用display属性,只需给元素添加“display:none;”样式即可。2、利用position和top属性设置元素绝对定位来隐藏元素,只需给元素添加“position:absolute;top:-9999px;”样式。

原来利用纯CSS也能实现文字轮播与图片轮播!原来利用纯CSS也能实现文字轮播与图片轮播!Jun 10, 2022 pm 01:00 PM

怎么制作文字轮播与图片轮播?大家第一想到的是不是利用js,其实利用纯CSS也能实现文字轮播与图片轮播,下面来看看实现方法,希望对大家有所帮助!

css3什么是自适应布局css3什么是自适应布局Jun 02, 2022 pm 12:05 PM

自适应布局又称“响应式布局”,是指可以自动识别屏幕宽度、并做出相应调整的网页布局;这样的网页能够兼容多个不同的终端,而不是为每个终端做一个特定的版本。自适应布局是为解决移动端浏览网页而诞生的,能够为使用不同终端的用户提供很好的用户体验。

css3如何实现鼠标点击图片放大css3如何实现鼠标点击图片放大Apr 25, 2022 pm 04:52 PM

实现方法:1、使用“:active”选择器选中鼠标点击图片的状态;2、使用transform属性和scale()函数实现图片放大效果,语法“img:active {transform: scale(x轴放大倍数,y轴放大倍数);}”。

css3动画效果有变形吗css3动画效果有变形吗Apr 28, 2022 pm 02:20 PM

css3中的动画效果有变形;可以利用“animation:动画属性 @keyframes ..{..{transform:变形属性}}”实现变形动画效果,animation属性用于设置动画样式,transform属性用于设置变形样式。

css3怎么设置动画旋转速度css3怎么设置动画旋转速度Apr 28, 2022 pm 04:32 PM

在css3中,可以利用“animation-timing-function”属性设置动画旋转速度,该属性用于指定动画将如何完成一个周期,设置动画的速度曲线,语法为“元素{animation-timing-function:速度属性值;}”。

一文了解CSS3中的新特性 ::target-text 选择器一文了解CSS3中的新特性 ::target-text 选择器Apr 12, 2022 am 11:24 AM

本篇文章带大家一起深入了解一下CSS3中的新特性::target-text 选择器,聊聊该选择器的作用和使用方法,希望对大家有所帮助!

css3线性渐变可以实现三角形吗css3线性渐变可以实现三角形吗Apr 25, 2022 pm 02:47 PM

css3线性渐变可以实现三角形;只需创建一个45度的线性渐变,设置渐变色为两种固定颜色,一个是三角形的颜色,另一个为透明色即可,语法“linear-gradient(45deg,颜色值,颜色值 50%,透明色 50%,透明色 100%)”。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前By尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

DVWA

DVWA

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

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。