给大家带来用纯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 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自适应全屏焦点图切换的特效怎么做的详细内容。更多信息请关注PHP中文网其他相关文章!

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

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

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

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

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

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

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

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


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

WebStorm Mac版
好用的JavaScript开发工具

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

Dreamweaver CS6
视觉化网页开发工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。