JQuery之手风琴效果(part3)

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

<!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>

结果:

猜你喜欢

转载自blog.csdn.net/weixin_41406727/article/details/88936485