html+css3+jQuery实现多图显示相册切换特效

2025-11-05 05:02:42

1、新建html文档。

html+css3+jQuery实现多图显示相册切换特效

2、书写hmtl代码。

<div class="container">

<div class="card-container-4">

    <div class="card first">

      <h1>1</h1>

    </div>

    <div class="card second">

      <h1>2</h1>

    </div>

    <div class="card third">

      <h1>3</h1>

    </div>

  </div>

</div>

html+css3+jQuery实现多图显示相册切换特效

3、初始化css代码。

<style>

html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}

</style>

html+css3+jQuery实现多图显示相册切换特效

4、书写css代码。

<style>

body { background: #000; font-family: 'avenir Next', 'sans-serif'; width: 100%; }

.container { position: relative; -webkit-transition: all .3s ease; transition: all .3s ease; padding: 40px 0; }

div[class*='card-container-'] { position: relative; margin: 40px auto; width: 200px; height: 200px; -webkit-perspective: 500px; perspective: 500px; }

.card-container-4 { color: #ffb9ad; }

.card-container-4 .card { position: absolute; left: 0; top: 0; width: 100%; height: 100%; -webkit-transition: all .3s ease; transition: all .3s ease; border-radius: 2px; background-color: tomato; box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2); }

.card-container-4 .card:last-of-type { z-index: 80; }

.card-container-4 .card:nth-last-of-type(2) { z-index: 90; }

.card-container-4 .card:first-of-type { z-index: 100; }

.card-container-4:hover .card:first-of-type { opacity: .8; }

.card-container-4:hover .card:first-of-type:hover { top: 0; }

.card-container-4:hover .card:first-of-type ~ .card { cursor: pointer; cursor: hand; }

.card-container-4:hover .first { -webkit-transform: scale(0.5) translateX(-105%); transform: scale(0.5) translateX(-105%); }

.card-container-4:hover .second { -webkit-transform: scale(0.5) translateX(0); transform: scale(0.5) translateX(0); }

.card-container-4:hover .third { -webkit-transform: scale(0.5) translateX(105%); transform: scale(0.5) translateX(105%); }

.card-container-4:hover .card:hover { top: -5px; }

</style>

html+css3+jQuery实现多图显示相册切换特效

5、书写JS并引用。

<script src="js/jquery.min.js"></script>

<script>

var cc4 = $('.card-container-4');

cc4.children('.card').click(function(){

  cc4.prepend($(this));

})

</script>

html+css3+jQuery实现多图显示相册切换特效

6、查看效果

html+css3+jQuery实现多图显示相册切换特效

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢