vue+jQuery制作图片变大缩小,文字内容结合滑动手风琴动画特效。页面代码简洁实用。 超级简单哦~
css代码
@charset "utf-8";
/* CSS Document */
body{margin: 0;padding: 0;}
ul{margin: 0;padding: 0; list-style: none;}
a{text-decoration: none;}
h3,p{margin: 0;font-weight: normal;}
.main_box{
width: 100%;
position: relative;
}
.box{
width: 1232px;
margin: 10px auto;
padding: 15px;
}
.box_ul_li{
width: 202px;
height: 300px;
box-shadow: 3px 2px 30px rgba(0,0,0,.1);
float: left;
text-align: center;
position: relative;
transition: all .6s ease-out;
}
.box ul li h3{
padding-top: 30px;
color: #333;
font-size: 18px;
}
.box ul li p{
margin-top: 7px;
color: #666;
font-size: 14px;
}
.box ul li img{
width: 150px;
position: absolute;
right: 26px;
bottom: 40px;
transition: all .6s ease-out;
}
.box ul .on{
width: 402px;
height: 400px;
background-color: #6ab0e8;
text-align: left;
}
.box ul .on h3{
padding-left: 20px;
color: #FFF;
}
.box ul .on p{
margin-left: 20px;
color: #FFF;
}
.box ul .on img{
width: 382px;
position: absolute;
right: 8px;
bottom: 10px;
border: 2px #3e3d3d solid;
}
html代码
<section class="main_box">
<div class="box" id="app">
<ul>
<li :class="li.class" v-for="li in data">
<a :href="li.href" target="_blank">
<h3>{{li.name}}</h3>
<p>{{li.text}}</p>
<img :src="li.src" alt="img">
</a>
</li>
<div style="clear: both"></div>
</ul>
</div>
</section>
js代码:记得引入jq和vue
<script src="js/jquery-1.12.1.min.js"></script>
<script src="js/vue.min.js"></script>
<script>
new Vue({
el: "#app",
data: function () {
return {
data:[
{class:"box_ul_li",href:"#",src:"images/1.jpg",name:"图片1",text:"文本1"},
{class:"box_ul_li on",href:"#",src:"images/2.jpg",name:"图片2",text:"文本2"},
{class:"box_ul_li",href:"#",src:"images/3.jpg",name:"图片3",text:"文本3"},
{class:"box_ul_li",href:"#",src:"images/4.jpg",name:"图片4",text:"文本4"},
{class:"box_ul_li",href:"#",src:"images/5.jpg",name:"图片5",text:"文本5"},
]
}
}
})
$(".box ul li").hover(function(){
$(this).addClass('on').siblings().removeClass('on');
});
</script>