登录  /  注册
首页 > web前端 > css教程 > 正文

CSS3自适应全屏焦点图切换的特效怎么做

php中世界最好的语言
发布: 2017-11-24 13:37:17
原创
1648人浏览过

给大家带来用纯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 &amp; Consulting</a></li>
                                               <li><a href="#bg3">My haire is sooo fantastic!</a></li>
                                               <li><a href="#bg4">Eat healthy &amp; excersice!</a></li>
                                               <li><a href="#bg5">Lips so kissable I could die ...</a></li>
                                     </ul>
                            </div>
                            <img src="img/bg1.jpg" class="bg slideLeft" id="bg1" />
                            <img src="img/bg2.jpg" class="bg slideBottom" id="bg2" />
                            <img src="img/bg3.jpg" class="bg zoomIn" id="bg3" />
                            <img src="img/bg4.jpg" class="bg zoomOut" id="bg4" />
                            <img src="img/bg5.jpg" class="bg rotate" id="bg5" />
                  
         </body>
</html>
登录后复制

自适应全屏焦点图切换的特效就这么多了。更多精彩请关注php中文网其它相关文章!

相关阅读:

CSS3有哪些新增的背景属性

怎么用CSS3媒体查询

css3的弹性盒怎么做出来

以上就是CSS3自适应全屏焦点图切换的特效怎么做的详细内容,更多请关注php中文网其它相关文章!

智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 技术文章
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2023 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号

登录PHP中文网,和优秀的人一起学习!
全站2000+教程免费学