您的位置:首页 > Web前端 > JQuery

JQuery之手风琴效果(part3)

2019-03-31 21:55 99 查看

今天来学手风琴。点击小图换为大图显示。运用了attr()方法

[code]<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
body,
html,
.wrapper ul {
margin: 0;
padding: 0;
}

.wrapper,
.wrapper ul {
width: 800px;
height: 200px;
overflow: hidden;
}

.wrapper ul li {
list-style: none;
height: 100%;
float: left;
width: 120px;
position: relative;
box-sizing: border-box;
}

.wrapper ul li.bigimg {
width: 100%;
height: 100%;
}

.wrapper ul li:first-child {
background: url(img/timg.jpg) no-repeat;
background-size: 320px 100%;
}

.wrapper ul li:nth-child(2) {
background: url(img/timg1.jpg) no-repeat;
background-size: 320px 100%;
}

.wrapper ul li:nth-child(3) {
background: url(img/timg3.jpg) no-repeat;
background-size: 320px 100%;
}

.wrapper ul li:nth-child(4) {
background: url(img/timg4.jpg) no-repeat;
background-size: 320px 100%;
}

.wrapper ul li:nth-child(5) {
background: url(img/timg5.jpg) no-repeat;
background-size: 320px 100%;
}

.wrapper ul li a {
height: 100%;
display: block;
}

.wrapper ul .bigimg a,
.wrapper ul li a {
width: 100%;
}

.bigimg {
width: 39.72% !important
}

.bigimg .info {
font-size: 20px;
}

.wrapper ul li.big a .mask {
bottom: 0;
left: 0;
right: 0;
z-index: 99;
position: absolute;
top: 0;
display: block;
background-color: rgba(0, 0, 0, .2);
}

.wrapper ul li.bigimg a .mask {
background-color: transparent
}

.wrapper ul li.big a:hover .mask {
opacity: 0;
transition: all 0.5s
}

.info {
position: absolute;
bottom: 43px;
left: -24px;
transform: rotate(-90deg);
}

.info h3 {
margin: 0;
padding: 0;
}

li a img {
position: absolute;
right: 0;
bottom: 0;
height: 100%;
width: 320px;
display: block;
}

li.bigimg {
z-index: 99;
}
</style>
</head>

<body>
<div id="subject" class="wrapper">
<ul>
<li class="big bigimg">
<a href="#link1">
<div class="info">
<h3 style="color:#f62368">石原里美</h3>
</div>
<i class="mask"></i>
</a>
</li>
<li class="big">
<a href="#link1">
<div class="info">
<h3 style="color:#f62368">石原里美</h3>
</div>
<s class="line"></s>
<i class="mask"></i>
</a>
</li>
<li class="big">
<a href="#link1">
<div class="info">
<h3 style="color:#f62368">石原里美</h3>
</div>
<s class="line"></s>
<i class="mask"></i>
</a>
</li>
<li class="big">
<a href="#link1">
<div class="info">
<h3 style="color:#f62368">石原里美</h3>
</div>
<s class="line"></s>
<i class="mask"></i>
</a>
</li>
<li class="big">
<a href="#link1">
<div class="info">
<h3 style="color:#f62368">石原里美</h3>
</div>
<s class="line"></s>
<i class="mask"></i>
</a>
</li>
</ul>
</div>
<script src="js/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$(".big").mouseover(function() {
$(".bigimg").attr("class", "big")
$(this).attr('class', 'bigimg');
})
})
</script>
</body>

</html>

结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: