div+css中设计鼠标悬停,第一行图像没法控制,老是跑到第二行,麻烦给看看
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="jquery-3.1.0.min.js"></script>
<style type="text/css">
body {
background: #f5f5f5;
}
#img ul {
height: 614px;
list-style: none;
}
#img ul li {
height: 315px;
background: #fff none repeat scroll 0 0;
float: left;
margin-bottom: 14px;
margin-left: 22px;
position: relative;
transition: all 0.2s linear 0s;
width: 265px;
z-index: 1;
list-style: none;
padding-top: 20px;
padding-bottom: 20px;
}
#img ul li.active {
box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
position: relative;
border-bottom-width: 2px;
border-bottom-style: solid;
border-bottom-color: #CC0000;
}
#img ul li a {
display: block;
text-decoration: none;
list-style: none;
position: absolute;
left: 50%;
margin-left: -110px;
color: #FF0000;
font-size: 14px;
line-height: 14px;
text-align: center;
}
#img ul li img {
width: 220px;
height: 220px;
border: 0 none;
}
#text{
color:#000000;
font-size: 16px;
font-weight: bold;
}
#text1{
color:#000000;
font-size: 12px;
font-weight: normal;
background-color: #F0F0F0;
line-height: 25px;
}
</style>
<script type="text/javascript">
window.onload = function() {
iHover();
}
function iHover() {
var oLi = document.getElementById("img").getElementsByTagName("li");
for (var i = 0; i < oLi.length; i++) {
oLi[i].onmouseover = function() {
this.setAttribute('class','active');
$(this).animate({
top:10
},30)
}
oLi[i].onmouseout = function(){
this.setAttribute('class','')
$(this).animate({
top:0
},30)
}
}
}
</script>
</head>
<body>
<div id="img">
<ul>
<li class="item">
<a href="#">
<img src="1.jpg" width="160px" height="160px" alt="">
<span >
<p id="text"><strong>52度盛世风韵西凤酒</strong>
零售价:<strong>¥59.00 </strong> 团购价:私聊
<p id="text1">精品凤香型 52%vol/500ml/每箱6瓶
</span>
</a>
</li>
<li class="item">
<a href="#">
<img src="1.jpg" width="160px" height="160px" alt="">
<span >
<p id="text"><strong>52度盛世风韵西凤酒</strong>
零售价:<strong>¥59.00 </strong> 团购价:私聊
<p id="text1">精品凤香型 52%vol/500ml/每箱6瓶
</span>
</a>
</li>
<li class="item">
<a href="#">
<img src="1.jpg" width="160px" height="160px" alt="">
<span >
<p id="text"><strong>52度盛世风韵西凤酒</strong>
零售价:<strong>¥59.00 </strong> 团购价:私聊
<p id="text1">精品凤香型 52%vol/500ml/每箱6瓶
</span>
</a>
</li>
<li class="item">
<a href="#">
<img src="1.jpg" width="160px" height="160px" alt="">
<span >
<p id="text"><strong>52度盛世风韵西凤酒</strong>
零售价:<strong>¥59.00 </strong> 团购价:私聊
<p id="text1">精品凤香型 52%vol/500ml/每箱6瓶
</span>
</a>
</li>
<li class="item">
<a href="#">
<img src="1.jpg" width="160px" height="160px" alt="">
<span >
<p id="text"><strong>52度盛世风韵西凤酒</strong>
零售价:<strong>¥59.00 </strong> 团购价:私聊
<p id="text1">精品凤香型 52%vol/500ml/每箱6瓶
</span>
</a>
</li>
</ul>
</div>
</body>
</html>