案例分析:
鼠标经过图片高亮,其他兄弟图片不高亮
图片素材可自己更换图片,这里不放素材了
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
ul {
/* 去掉列表前面的符号 */
list-style: none;
}
body {
background: #000;
}
.wrap {
margin: 100px auto 0;
width: 630px;
height: 394px;
padding: 10px 0 0 10px;
background: #000;
/* 内容会被修剪,并且其余内容不可见 */
overflow: hidden;
border: 1px solid #fff;
}
.wrap li {
/* 元素沿其容器的左侧放置 */
float: left;
margin: 0 10px 10px 0;
}
.wrap img {
display: block;
border: 0;
}
style>
<script src="jquery.min.js">script>
<script>
$(function() {
// 鼠标进入的时候,其他的li 标签透明度;0.5
$(".wrap li").hover(function() {
$(this).siblings().stop().fadeTo(400,0.5);
}, function() {
// 鼠标离开,其他的 li 透明度改为1
$(this).siblings().stop().fadeTo(400,1);
})
})
script>
head>
<body>
<div class="wrap">
<ul>
<li><a href="#"><img src="../code/23-高亮显示案例/images/01.jpg" alt="">a>li>
<li><a href="#"><img src="../code/23-高亮显示案例/images/02.jpg" alt="">a>li>
<li><a href="#"><img src="../code/23-高亮显示案例/images/03.jpg" alt="">a>li>
<li><a href="#"><img src="../code/23-高亮显示案例/images/04.jpg" alt="">a>li>
<li><a href="#"><img src="../code/23-高亮显示案例/images/05.jpg" alt="">a>li>
<li><a href="#"><img src="../code/23-高亮显示案例/images/06.jpg" alt="">a>li>
ul>
div>
body>
html>
显示:
案例:王者荣耀手风琴效果分析
doctype html>
<html>
<head>
<meta charset="utf-8">
<title>手风琴案例title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
img {
display: block;
}
ul {
list-style: none;
}
.king {
width: 852px;
margin: 100px auto;
background: url(images/bg.png) no-repeat;
overflow: hidden;
padding: 10px;
}
.king ul {
overflow: hidden;
}
.king li {
position: relative;
float: left;
width: 69px;
height: 69px;
margin-right: 10px;
}
.king li.current {
width: 224px;
}
.king li.current .big {
display: block;
}
.king li.current .small {
display: none;
}
.big {
width: 224px;
display: none;
}
.small {
position: absolute;
top: 0;
left: 0;
width: 69px;
height: 69px;
border-radius: 5px;
}
style>
head>
<body>
<script src="js/jquery.min.js">script>
<script type="text/javascript">
$(function() {
// 鼠标经过某个小li 有两步操作:
$(".king li").mouseenter(function() {
// 1.当前小li 宽度变为 224px, 同时里面的小图片淡出,大图片淡入
$(this).stop().animate({
width: 224
}).find(".small").stop().fadeOut().siblings(".big").stop().fadeIn();
// 2.其余兄弟小li宽度变为69px, 小图片淡入, 大图片淡出
$(this).siblings("li").stop().animate({
width: 69
}).find(".small").stop().fadeIn().siblings(".big").stop().fadeOut();
})
});
script>
<div class="king">
<ul>
<li class="current">
<a href="#">
<img src="images/m1.jpg" alt="" class="small">
<img src="images/m.png" alt="" class="big">
a>
li>
<li>
<a href="#">
<img src="images/l1.jpg" alt="" class="small">
<img src="images/l.png" alt="" class="big">
a>
li>
<li>
<a href="#">
<img src="images/c1.jpg" alt="" class="small">
<img src="images/c.png" alt="" class="big">
a>
li>
<li>
<a href="#">
<img src="images/w1.jpg" alt="" class="small">
<img src="images/w.png" alt="" class="big">
a>
li>
<li>
<a href="#">
<img src="images/z1.jpg" alt="" class="small">
<img src="images/z.png" alt="" class="big">
a>
li>
<li>
<a href="#">
<img src="images/h1.jpg" alt="" class="small">
<img src="images/h.png" alt="" class="big">
a>
li>
<li>
<a href="#">
<img src="images/t1.jpg" alt="" class="small">
<img src="images/t.png" alt="" class="big">
a>
li>
ul>
div>
body>
html>
显示: