ul.html 4.12 KB
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>仿高德</title>
  <script src='jquery-3.3.1.js'></script>
  <style>
  body,div,ul,li{
    padding:0;
	margin:0;
  }
  .header{
    height:70px;
	min-width:1280px;
    background: #000;
  }
  .header-core{
    width:1220px;		
	margin:0 auto;	
  }
  .logo img{  
    width: 307px;
    height: 42px;
    display: inline-block;
    margin: 14px 23px 0 0;
  }
   .header ul{
    display: inline-block;
    color: #fff;
    position: relative;
    top: -16px;
  }
   .header ul li{
	 list-style:none;
	 display:inline-block;	
     width:84px;
     margin-right:14px; 
   }
   ul li{
    list-style:none;
   }
    .header ul li:hover{
	 color:red;
   }
   .header ul li a{
     text-decoration:none;
   }
   input{
    background:rgb(79, 88, 98);
    border-radius: 10px;
    width: 86px;
    height: 30px;
	border: none;
	 position: relative;
    top: -16px;
   }
   
   .ct ul{
      width:1000px;
	  margin:16px auto;
	 
   }
   
   .ct ul li{
    background:#efefef;
    width: 240px;
    height: 240px;
	margin:25px;
	position:relative;
	display:inline-block;
	opacity:1;
   }
   .intro{
     padding:25px;
   }
   .mask{
     opacity:0;
	 background-color: rgba(0, 0, 0, .6);
	 position:absolute;
	 top:0;
	 left:0;
   }
   
    .ct ul li:hover .mask {
    opacity: 1;
    background-color: rgba(0, 0, 0, .6);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    color: #fff;
   }
   
   .ct2 ul{
       position:relative;   
	       height: 320px;
   }
   
   .ct2 ul li{
    background-color: rgba(0, 0, 0, 0.6);
	position:absolute;	
	bottom: 0;
	transition:height 0.4s;	
   }
   
    .ct2 ul li:before{
	   content:'';
	   background:#a3a3a3;
	   position:absolute;
       width: 240px;
       height: 240px;	   
	   opacity:0.5;
	}
   
    .ct2 ul .li-0{
       margin-left:0;	
	   background-image:url("img/1.jpg");
	   background-size:contain;
	   z-index:10;
   }
   
    .ct2 ul .li-1{
      margin-left:120px;	
	   background-image:url("img/2.jpg");
	   background-size:contain;	 	
   }
   
    .ct2 ul .li-2{
       margin-left:240px;	
	   background-image:url("img/3.jpg");
	   background-size:contain;
	   z-index:10;	
   }
   
   .ct2 ul li.current {
        z-index:999;
		width: 240px;
        height: 280px;
        margin-top: -15px;
		
   }   
   
   .ct2 ul li.current:before {
      opacity:0;
   }
   
</style>
</head>
<body>
<div class="header">
<div class="header-core">
  <a class="logo" href="#"><img src="https://lbs.amap.com/web/public/dist/images/logo_white_2x.cad826.png"/></a>
  <ul>
    <li>产品介绍</li>
	<li>开发支持</li>
	<li>解决方案</li>
	<li>高德位智</li>
	<li>商务合作</li>
  </ul>
  <input>
</div>
<div class="header-radight">
  <a></a>
</div>
</div>
<div class="ct">
  <ul>
    <li>
	   <div class="intro">
	        <div>产品介绍</div>
			<div class="mask">qweeeeeeeee</div>
	   </div>	 
	</li>
	 <li>
	   <div class="intro">
	        <div>产品介绍</div>
			<div class="mask">qweeeeeeeee</div>
	   </div>	 
	</li>
	 <li>
	   <div class="intro">
	        <div>产品介绍</div>
			<div class="mask">qweeeeeeeee</div>
	   </div>	 
	</li>
  </ul>     
</div>
<div class="ct ct2">
  <ul  class="ct2ul">
    <li class="li-0">
	   <div class="intro">
	        <div>产品介绍</div>			
	   </div>	 
	</li>
	 <li class="li-1 current">
	   <div class="intro">
	        <div>产品介绍</div>			
	   </div>	 
	</li>
	 <li class="li-2">
	   <div class="intro">
	        <div>产品介绍</div>			
	   </div>	 
	</li>
  </ul>     
</div>
<script>
$("ul.ct2ul li").hover(function(){
  console.log($(this).index())
   $('ul.ct2ul li').removeClass('current');
   $(this).addClass('current');  
   let currentIndex = $(this).index;
   $(this).css("z-index",999)
   let total = 3;
   let pre = $(this);
   let next = $(this);
   let zindex = 10
   for(let i = 0;i<total;i++){   
     if(pre.prev().length>0){
	    pre = pre.prev();
		console.log("pre",pre.attr("class") ,i)
		pre.css("z-index",10-i)
	 }
	 if(next.next().length>0){
	   next = next.next();
	   console.log("next",next.attr("class") ,i)
	   next.css("z-index",10-i)
	 }
   }   
})
</script>
</body>
</html>