CSS3 Full Background Slider

特别声明:如果您喜欢小站的内容,可以点击申请会员进行全站阅读。如果您对付费阅读有任何建议或想法,欢迎发送邮件至: airenliao@gmail.com!或添加QQ:874472854(^_^)

CSS3 Full Background Slider

今天在365psd上看到一个psd效果,很有意思,想着能不能转成web页面,这问题想得太SB了,然后接着想,转成带有css3的动画效果。那转成什么呢?思来想去做了一个全屏背景图的幻灯片效果。虽然是一个简单的demo,但里面集合了CSS3众多属性,从伪结构选择器,到圆角,阴影以及动画等。

demodownload

咱就不多说了,直接上代码来得实际

HTML结构

<div class="slider">
  <ul class="clearfix">
    <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="bg1.jpg" alt="" class="bg slideLeft" id="bg1" />
<img src="bg2.jpg" alt="" class="bg slideBottom" id="bg2" /> 
<img src="bg3.jpg" alt="" class="bg zoomIn" id="bg3" />>
<img src="bg4.jpg" alt="" class="bg zoomOut" id="bg4" />
<img src="bg5.jpg" alt="" class="bg rotate" id="bg5" />

CSS代码

 *{
  margin: 0;
  padding: 0;
}
html,body {
  height: 100%;
}
img.bg {
  /* Set rules to fill background */
  min-height: 100%;
  min-width: 1024px;
  /* Set up proportionate scaling */
  width: 100%;
  height: auto !important;
  height: 100%;
  /* Set up positioning */
  position: fixed;
  top: 0;
  left: 0;
  z-index:1;
}
@media screen and (max-width: 1024px) { /* Specific to this particular image */
  img.bg {
    left: 50%;
    margin-left: -512px;   /* 50% */
  }
}
.slider {
  position: absolute;
  width: 100%;
  text-align: center;
  z-index: 9999;
  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: #fff;
  text-decoration: none;
  font-size: 22px;
  font-family: 'Yesteryear', cursive;
  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 {
  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 {
  background: url(sbg1.jpg) no-repeat center;
}
.slider li:nth-of-type(2) a::after {
  background: url(sbg2.jpg) no-repeat center;
}
.slider li:nth-of-type(3) a::after {
  background: url(sbg3.jpg) no-repeat center;
}
.slider li:nth-of-type(4) a::after {
  background: url(sbg4.jpg) no-repeat center;
}
.slider li:nth-of-type(5) a::after {
  background: url(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;
}
/* Slide Left */
 
@-webkit-keyframes 'slideLeft' {
	0% { left: -500px; }
	100% { left: 0; }
}
@-moz-keyframes 'slideLeft' {
	0% { left: -500px; }
	100% { left: 0; }
}
@-o-keyframes 'slideLeft' {
	0% { left: -500px; }
	100% { left: 0; }
}
@-ms-keyframes 'slideLeft' {
	0% { left: -500px; }
	100% { left: 0; }
}
@keyframes 'slideLeft' {
	0% { left: -500px; }
	100% { left: 0; }
}
 
.slideLeft:target {
	z-index: 100;
	-webkit-animation-name: slideLeft;
	-webkit-animation-duration: 1s;
	-webkit-animation-iteration-count: 1;
	-moz-animation-name: slideLeft;
	-moz-animation-duration: 1s;
	-moz-animation-iteration-count: 1;
	-ms-animation-name: slideLeft;
	-ms-animation-duration: 1s;
	-ms-animation-iteration-count: 1;
	-o-animation-name: slideLeft;
	-o-animation-duration: 1s;
	-o-animation-iteration-count: 1;
	animation-name: slideLeft;
	animation-duration: 1s;
	animation-iteration-count: 1;
}
 
 
/* Slide Bottom */
 
@-webkit-keyframes 'slideBottom' {
	0% { top: 350px; }
	100% { top: 0; }
}
@-moz-keyframes 'slideBottom' {
	0% { top: 350px; }
	100% { top: 0; }
}
@-ms-keyframes 'slideBottom' {
	0% { top: 350px; }
	100% { top: 0; }
}
@-o-keyframes 'slideBottom' {
	0% { top: 350px; }
	100% { top: 0; }
}
@keyframes 'slideBottom' {
	0% { top: 350px; }
	100% { top: 0; }
}
 
.slideBottom:target {
	z-index: 100;
 
	-webkit-animation-name: slideBottom;
	-webkit-animation-duration: 1s;
	-webkit-animation-iteration-count: 1;
	-moz-animation-name: slideBottom;
	-moz-animation-duration: 1s;
	-moz-animation-iteration-count: 1;
	-ms-animation-name: slideBottom;
	-ms-animation-duration: 1s;
	-ms-animation-iteration-count: 1;
	-o-animation-name: slideBottom;
	-o-animation-duration: 1s;
	-o-animation-iteration-count: 1;
  animation-name: slideBottom;
	animation-duration: 1s;
	animation-iteration-count: 1;
}
 
/* Zoom In */
 
@-webkit-keyframes 'zoomIn' {
	0% { -webkit-transform: scale(0.1); }
	100% { -webkit-transform: none; }
}
@-moz-keyframes 'zoomIn' {
	0% { -moz-transform: scale(0.1); }
	100% { -moz-transform: none; }
}
@-ms-keyframes 'zoomIn' {
	0% { -ms-transform: scale(0.1); }
	100% { -ms-transform: none; }
}
@-o-keyframes 'zoomIn' {
	0% { -o-transform: scale(0.1); }
	100% { -o-transform: none; }
}
@keyframes 'zoomIn' {
	0% { transform: scale(0.1); }
	100% { transform: none; }
}
.zoomIn:target {
	z-index: 100;
	-webkit-animation-name: zoomIn;
	-webkit-animation-duration: 1s;
	-webkit-animation-iteration-count: 1;
	-moz-animation-name: zoomIn;
	-moz-animation-duration: 1s;
	-moz-animation-iteration-count: 1;
	-ms-animation-name: zoomIn;
	-ms-animation-duration: 1s;
	-ms-animation-iteration-count: 1;
	-o-animation-name: zoomIn;
	-o-animation-duration: 1s;
	-o-animation-iteration-count: 1;
	animation-name: zoomIn;
	animation-duration: 1s;
	animation-iteration-count: 1;
}
 
/* Zoom Out */
 
@-webkit-keyframes 'zoomOut' {
	0% { -webkit-transform: scale(2); }
	100% { -webkit-transform: none; }
}
@-moz-keyframes 'zoomOut' {
	0% { -moz-transform: scale(2); }
	100% { -moz-transform: none; }
}
@-ms-keyframes 'zoomOut' {
	0% { -ms-transform: scale(2); }
	100% { -ms-transform: none; }
}
@-o-keyframes 'zoomOut' {
	0% { -o-transform: scale(2); }
	100% { -o-transform: none; }
}
@keyframes 'zoomOut' {
	0% { transform: scale(2); }
	100% { transform: none; }
}
 
.zoomOut:target {
	z-index: 100;
	-webkit-animation-name: zoomOut;
	-webkit-animation-duration: 1s;
	-webkit-animation-iteration-count: 1;
	-moz-animation-name: zoomOut;
	-moz-animation-duration: 1s;
	-moz-animation-iteration-count: 1;
	-ms-animation-name: zoomOut;
	-ms-animation-duration: 1s;
	-ms-animation-iteration-count: 1;
	-o-animation-name: zoomOut;
	-o-animation-duration: 1s;
	-o-animation-iteration-count: 1;
	animation-name: zoomOut;
	animation-duration: 1s;
	animation-iteration-count: 1;
}
 
/* Rotate */
 
@-webkit-keyframes 'rotate' {
	0% { -webkit-transform: rotate(-360deg) scale(0.1); }
	100% { -webkit-transform: none; }
}
@-moz-keyframes 'rotate' {
	0% { -moz-transform: rotate(-360deg) scale(0.1); }
	100% { -moz-transform: none; }
}
@-ms-keyframes 'rotate' {
	0% { -ms-transform: rotate(-360deg) scale(0.1); }
	100% { -ms-transform: none; }
}
@-o-keyframes 'rotate' {
	0% { -o-transform: rotate(-360deg) scale(0.1); }
	100% { -o-transform: none; }
}
@keyframes 'rotate' {
	0% { transform: rotate(-360deg) scale(0.1); }
	100% { transform: none; }
}
 
.rotate:target {
	z-index: 100;
	-webkit-animation-name: rotate;
	-webkit-animation-duration: 1s;
	-webkit-animation-iteration-count: 1;
	-moz-animation-name: rotate;
	-moz-animation-duration: 1s;
	-moz-animation-iteration-count: 1;
	-ms-animation-name: rotate;
	-ms-animation-duration: 1s;
	-ms-animation-iteration-count: 1;
	-o-animation-name: rotate;
	-o-animation-duration: 1s;
	-o-animation-iteration-count: 1;
	animation-name: rotate;
	animation-duration: 1s;
	animation-iteration-count: 1;
}
 
/* Not Target */
 
@-webkit-keyframes 'notTarget' {
	0% { z-index: 75; }
	100% { z-index: 75; }
}
@-moz-keyframes 'notTarget' {
	0% { z-index: 75; }
	100% { z-index: 75; }
}
@-ms-keyframes 'notTarget' {
	0% { z-index: 75; }
	100% { z-index: 75; }
}
@-o-keyframes 'notTarget' {
	0% { z-index: 75; }
	100% { z-index: 75; }
}
@keyframes 'notTarget' {
	0% { z-index: 75; }
	100% { z-index: 75; }
}
 
.bg:not(:target) {
	-webkit-animation-name: notTarget;
	-webkit-animation-duration: 1s;
	-webkit-animation-iteration-count: 1;
	-moz-animation-name: notTarget;
	-moz-animation-duration: 1s;
	-moz-animation-iteration-count: 1;
	-ms-animation-name: notTarget;
	-ms-animation-duration: 1s;
	-ms-animation-iteration-count: 1;
	-o-animation-name: notTarget;
	-o-animation-duration: 1s;
	-o-animation-iteration-count: 1;
	animation-name: notTarget;
	animation-duration: 1s;
	animation-iteration-count: 1;
}

文中特殊字体来自于google webfonts

<link href='http://fonts.googleapis.com/css?family=Yesteryear' rel='stylesheet' type='text/css'>

demodownload

特别声明:此设计图来自于365psdBojana Cakic设计的设计效果

如需转载,烦请注明出处:http://www.w3cplus.com/demo/CSS3-Full-Background-Slider.html

nike free run 5.0 hyperfuse

如需转载,烦请注明出处:https://www.w3cplus.com/demo/405.html

如果文章中有不对之处,烦请各位大神拍正。如果你觉得这篇文章对你有所帮助,打个赏,让我有更大的动力去创作。(^_^)。看完了?还不过瘾?点击向作者提问!

赏杯咖啡,鼓励他创作更多优质内容!
返回顶部