div上的Jquery / CSS轮播/滑块效果

时间:2016-08-15 19:13:35

标签: javascript jquery html css css3

我已经设置了3个div,一个在左边,另外两个在右边。

我希望'onclick'让左边的div从左边滑出 右上角的一个div上升,右下角的一个div从右侧滑入。

在完成动画制作之后,我希望下次我按下“onclick”按钮对下一个div (具有不同内容)执行相同的操作,以便从之前的div来到的点进入

我设法改变了div的背景颜色,但没有改变内容和动画。

这是我到目前为止所得到的。

$(document).ready(function(){
  $('#next').click(function(){
    if ($('.active').next('.case').length) {
        $('.active').removeClass('active')
                    .next('.case')
                    .addClass('active');
    }
  });
  $('#prev').click(function(){
    if ($('.active').prev('.case').length) {
        $('.active').removeClass('active')
                    .prev('.case')
                    .addClass('active');
    }
  });
});
html,body,section{
	margin: 0px;
	padding: 0px;
	width: 100%;
	height: 100%;
}

#next,#prev{
  position:fixed;
  z-index:101;
}

#next{
  right:0px;
}

#prev{
  left:0px;
}

#t1{
  float:left;
  height:100%;
  width:43%;
  background-color: #c92639;
      position: absolute;
    left: 0px;
  
  
}

#logo >h1{
	color: white;
}

#logo >h3{
	    width: 58%;
    margin: 0 auto;

}
#t2,#t3{
height: 50%;
    width: 57%;
    margin-left: auto;
    margin-right: 0px;
}

#t3{
      position: absolute;
    right: 0px;
    bottom: 0px;
   background-color: #c8c8c8;
}
#t2{
	background-color: white;
      position: absolute;
    right: 0px;
    top: 0px;
}

#t2 >img{
	margin-top: 11%;
}

#logo{
	margin-top: 40%;
}

#t3>ul{
	display: inline-table;
	width: 80%;
	margin: 0 auto;
	margin-top: 50px;
}

#t3>ul>li{
	display: inline-table;
	width: 33%;

}

#t3>ul>li>div>img{
	width: 53%;
    margin-top: 25%;
}

#home{
	display: none !important;
}

#circle1,#circle2,#circle3{
    border-radius: 128px;
    width: 150px;
    height: 150px;
    margin: 0 auto;
    box-shadow: 10px 10px 5px #888888;
}

#circle1{
	background: #32325f;
}

#circle2{
	background: white;
}

#circle3{
	background: #ef9d34;
}

.active{
  display:initial !important;
  z-index:100;
  
}

#case{
  display:none;
  position:absolute;
  top:0px;
  height: 100%;
  width: 100%;
  z-index:99;
}

.stern1{
  background:blue;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="next">
  <h1>next</h1>
</div>
<div id="prev">
  <h1>prev</h1>
</div>

<div id="case" class="case active">
<div id="t1" class="tcee1">
        <div id="logo"><img src="img/cee.png" id="cee">
            <div id="underline"></div>
            <br>
            <h1>BRINGING AN OFFLINE ENCOUNTER TO AN ONLINE RELATION</h1><br>
            <h3>Every day Cee-Platform helps their customers to build a bridge between their offline and online marketing challenges.</h3>
        </div>
    </div>
  
    <div id="t2" class="case tcee2">
        <img src="img/ceedev.png">
    </div>
    <div id="t3" class="tcee3">
        <ul>
            <li>
                <div id="circle1">
                <img src="img/computer.png">
                </div>
                <br>
                <div id="underline"></div>
                <h2>Responsiv</h2><br>
                <p>My expierences with developing websites has learned me to make them structualy responsive from the ground up making it accesible for all platforms</p>
            </li>
            <li>
                <div id="circle2">
                <img src="img/g.png">
                </div>
                <br>
                <div id="underline"></div>
                <h2>SEO</h2><br>
                <p>Optimizing your website to result with high results on googles googles list</p>            
            </li>
            <li>
                <div id="circle3">
                <img src="img/hand.png">
                </div>
                <br>
                <div id="underline"></div>
                <h2>Storytelling</h2><br>
                <p>With every website you want to tell a story, it doens't matter if you want to tell your visitor how aswesome your compeny or how important your goal is. I'll make it the best one out there</p>
            </li>
        </ul>
    </div>
</div>

<div id="case" class="case">
<div id="t1" class="tstern1" style="background:blue;">
        <div id="logo"><img src="img/cee.png" id="cee">
            <div id="underline"></div>
            <br>
            <h1>BRINGING AN OFFLINE ENCOUNTER TO AN ONLINE RELATION</h1><br>
            <h3>Every day Cee-Platform helps their customers to build a bridge between their offline and online marketing challenges.</h3>
        </div>
    </div>
    <div id="t2" class="tstern2">
        <img src="img/ceedev.png">
    </div>
    <div id="t3" class="tstern3">
        <ul>
            <li>
                <div id="circle1">
                <img src="img/computer.png">
                </div>
                <br>
                <div id="underline"></div>
                <h2>Responsiv</h2><br>
                <p>My expierences with developing websites has learned me to make them structualy responsive from the ground up making it accesible for all platforms</p>
            </li>
            <li>
                <div id="circle2">
                <img src="img/g.png">
                </div>
                <br>
                <div id="underline"></div>
                <h2>SEO</h2><br>
                <p>Optimizing your website to result with high results on googles googles list</p>            
            </li>
            <li>
                <div id="circle3">
                <img src="img/hand.png">
                </div>
                <br>
                <div id="underline"></div>
                <h2>Storytelling</h2><br>
                <p>With every website you want to tell a story, it doens't matter if you want to tell your visitor how aswesome your compeny or how important your goal is. I'll make it the best one out there</p>
            </li>
        </ul>
    </div>
</div>

<div id="case" class="case">
<div id="t1" class="tstern1" style="background:black;">
        <div id="logo"><img src="img/cee.png" id="cee">
            <div id="underline"></div>
            <br>
            <h1>BRINGING AN OFFLINE ENCOUNTER TO AN ONLINE RELATION</h1><br>
            <h3>Every day Cee-Platform helps their customers to build a bridge between their offline and online marketing challenges.</h3>
        </div>
    </div>
    <div id="t2" class="tstern2">
        <img src="img/ceedev.png">
    </div>
    <div id="t3" class="tstern3">
        <ul>
            <li>
                <div id="circle1">
                <img src="img/computer.png">
                </div>
                <br>
                <div id="underline"></div>
                <h2>Responsiv</h2><br>
                <p>My expierences with developing websites has learned me to make them structualy responsive from the ground up making it accesible for all platforms</p>
            </li>
            <li>
                <div id="circle2">
                <img src="img/g.png">
                </div>
                <br>
                <div id="underline"></div>
                <h2>SEO</h2><br>
                <p>Optimizing your website to result with high results on googles googles list</p>            
            </li>
            <li>
                <div id="circle3">
                <img src="img/hand.png">
                </div>
                <br>
                <div id="underline"></div>
                <h2>Storytelling</h2><br>
                <p>With every website you want to tell a story, it doens't matter if you want to tell your visitor how aswesome your compeny or how important your goal is. I'll make it the best one out there</p>
            </li>
        </ul>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

看看这个简单的教程,它对我来说很好,你也可以添加/改进它。

simple javascript slideshow

相关问题