如何在CSS

时间:2017-03-20 13:41:57

标签: javascript jquery html css css3



body {
  background-image: url("back.jpg");
  background-attachment: fixed;
  font-family: 'Open Sans', serif;
  color: white;
}
#container {
  height: 1000px;
}
/* HEADER WITH NAV BAR AND LOGIN SNIPPET */
#head {
  position: absolute;
  height: 150px;
  width: 100%;
  background-color: #ffffff;
  right: 0px;
  left: 0px;
  top: 0px;
}

#logo-image {
  position: relative;
  margin-top: 40px;
  margin-left: 40px;
}

#logo-image:hover {
  -webkit-animation: blur 0.5s ease-in;
}

@-webkit-keyframes blur {
  0% {
    -webkit-filter: blur(0px);
    filter: blur(0px);
  }
  50% {
    -webkit-filter: blur(1px);
    filter: blur(2px);
  }
  100% {
    -webkit-filter: blur(0px);
    filter: blur(0px);
  }
}

.navbar-fixed {
  top: 0;
  z-index: 100;
  position: fixed;
  width: 100%;
}

.navigationmenu-main {
  list-style-type: none;
  overflow: hidden;
  background-color: #333;
}

.navigationmenu-parent {
  float: left;
}

.navigationmenu-child {
  display: inline-block;
  color: white;
  width: 50px;
  text-align: center;
  padding: 10px 16px;
  text-decoration: none;
  background-color: #333;
  -webkit-transition: background-color .3s;
}

.navigationmenu-child:hover {
  background-color: #111;
}

.navigationmenu-child:hover + .navigationmenu-line {
  width: 100%;
}

.navigationmenu-line {
  height: 3px;
  background-color: red;
  width: 0%;
  -webkit-transition: width .3s;
  -webkit-transition-timing-function: ease;
}

.login-parent {
  float: right;
}

.login-child {
  display: inline-block;
  color: white;
  width: auto;
  text-align: center;
  padding: 10px 16px;
  text-decoration: none;
  background-color: #333;
  -webkit-transition: background-color .3s;
}

.login-child:hover {
  background-color: #111;
}

.login-child:hover + .navigationmenu-line {
  width: 100%;
}

#loginbox {
  display: block;
  visibility: hidden;
  position: absolute;
  top: 132px;
  right: 90px;
  z-index: 999;
  background: #a6a6a6;
  background-image: linear-gradient(top, #fff, #eee);
  padding: 15px;
  box-shadow: 0 2px 2px -1px rgba(0, 0, 0, .9);
  border-radius: 3px 0 3px 3px;
  -webkit-transition: padding .3s;
}

.login-parent:hover #loginbox {
  visibility: visible;
}

#loginform {
  padding: 5px;
}

#loginelement {
  padding: 5px;
}
/*----------------------*/
/* MAIN BODY */
#main{
	position: relative;
  height: 100%;
  width: 90%;
  margin-left: auto;
  margin-right: auto;
  background-color: #ffffff;
  top: 0px;
  bottom: 100px;
}
#box {
  position: relative;
  height: 100%;
  width: 90%;
  margin-left: auto;
  margin-right: auto;
  background-color: rgba(255,255,255,0.4);
  top: 140px;
  bottom: 100px;
  box-shadow: 4px 4px 3px 1px rgba(0,0,0,0.4);
}
/*---------------*/
/* SLIDER */
.slider {
  max-width: 100%;
  height: 500px;
  margin: 20px auto;
  position: absolute;
  top: 130px;
  left: 0px;
  right: 0px;
}
.slide1,.slide2,.slide3,.slide4,.slide5 {
  position: absolute;
  width: 100%;
  height: 100%;
}
.slide1 {
  background: url("1.jpg")no-repeat center;
      background-size: cover;
    animation:fade 8s infinite;
-webkit-animation:fade 8s infinite;
} 
.slide2 {
  background: url("2.jpeg")no-repeat center;
      background-size: cover;
    animation:fade2 8s infinite;
-webkit-animation:fade2 8s infinite;
}
.slide3 {
    background: url("3.jpg")no-repeat center;
      background-size: cover;
    animation:fade3 8s infinite;
-webkit-animation:fade3 8s infinite;
}
@keyframes fade
{
  0%   {opacity:1}

  33.333% { opacity: 0}
  66.666% { opacity: 0}
  100% { opacity: 1}
}
@keyframes fade2
{
  0%   {opacity:0}
  33.333% { opacity: 1}
  66.666% { opacity: 0 }
  100% { opacity: 0}
}
@keyframes fade3
{
  0%   {opacity:0}
  33.333% { opacity: 0}
  66.666% { opacity: 1}
  100% { opacity: 0}
}
/*-----------------*/
/* FOOT AREA FIXED */
#foot {
  position: fixed;
  height: 80px;
  width: 100%;
  background-color: #333;
  right: 0px;
  left: 0px;
  bottom: 0px;
}

<!DOCTYPE html>
<html>

  <head>
    <title>
      Le Meridian | A home away from home
    </title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
  </head>
  <!DOCTYPE html>
  <title>
    Le Meridian | A home away from home
  </title>

  <body>
    <div id="container">
      <div id="head">
        <img src="logo.png" id="logo-image" height="20%" width="20%">
        <ul id="nav_bar" class="navigationmenu-main">
          <li class="navigationmenu-parent">
            <a href="" class="navigationmenu-child">A</a>
            <div class="navigationmenu-line">
            </div>
          </li>
          <li class="navigationmenu-parent">
            <a href="" class="navigationmenu-child">B</a>
            <div class="navigationmenu-line">
            </div>
          </li>
          <li class="navigationmenu-parent">
            <a href="" class="navigationmenu-child">C</a>
            <div class="navigationmenu-line">
            </div>
          </li>
          <li class="navigationmenu-parent">
            <a href="" class="navigationmenu-child">D</a>
            <div class="navigationmenu-line">
            </div>
          </li>
          <li class="navigationmenu-parent">
            <a href="" class="navigationmenu-child">E</a>
            <div class="navigationmenu-line">
            </div>
          </li>
          <li class="navigationmenu-parent">
            <a href="" class="navigationmenu-child">F</a>
            <div class="navigationmenu-line">
            </div>
          </li>
          <li class="navigationmenu-parent">
            <a href="" class="navigationmenu-child">G</a>
            <div class="navigationmenu-line">
            </div>
          </li>
          <li class="login-parent">
            <div class="login-child">Sign Up</div>
            <div class="navigationmenu-line">
            </div>
          </li>
          <li class="login-parent">
            <div class="login-child" id="trigger">Login ▼</div>
            <div class="navigationmenu-line">
            </div>
            <div id="loginbox">
              <form id="loginform">
                <input type="text" name="email" id="loginelement" placeholder="UserId / email">
                <br>
                <br>
                <input type="password" name="password" id="loginelement" placeholder="Password">
                <br>
                <br>
                <input type="submit" name="loginsubmit" id="loginelement">
                <input type="checkbox" name="loggedin" id="loginelement"> Stay Signed In
              </form>
            </div>
          </li>
        </ul>
      </div>
      <div class='slider'>
			  <div class='slide1'></div>
			  <div class='slide2'></div>
			  <div class='slide3'></div>
			</div>
        	
      <div id="foot">
        <p align="Center">
          Windsor Place, New Delhi, New Delhi, 110001, India
        </p>
      </div>
    </div>
  </body>

</html>
&#13;
&#13;
&#13;

我正在制作一张CSS图片幻灯片,但是我无法在1个动画片中将图片1逐渐淡出,图片2会逐渐消失。请帮忙 我希望淡入淡出变得平滑,即第一张图片的淡出应该从第二张淡入淡出开始

1 个答案:

答案 0 :(得分:0)

我认为你不需要多个幻灯片div用于不同的背景,只使用一个

<div class="slider">
    <div class="slide1"></div>
</div>

和css

.slide1 {
   position: absolute;
   width: 300px;
   height: 200px;
   background: url("https://unsplash.it/200/300") no-repeat center;
   background-size: cover;
   animation:fade 8s infinite;
   -webkit-animation:fade 8s infinite;
} 

@keyframes fade {
   0%   {
     background: url("1.jpg") no-repeat center;
   }
   33.333% {
      background: url("2.jpg") no-repeat center;
   }
   66.666% {
      background: url("3.jpg") no-repeat center;
   }
   100% {
      background: url("1.jpg") no-repeat center;
   }
}