I have some divs and have some effects on it thorugh jQuery. When I hover over a div it expands. But then the divs beside and beneath it move along with it. I want the same effect like the expandable user card given on * after 1k repuration.
我有一些div并且对它有一些影响。当我将鼠标悬停在div上时会扩展。但随后它旁边和下面的div一起移动。我想要像1k repuration后在*上给出的可扩展用户卡一样的效果。
This is what I have done.
这就是我所做的。
JS:
$(document).ready(function () {
var delay = 1000;
$(".user").hover(function () {
$(this).css("background-color", "#eee");
$(this).delay(delay).animate({
width: '350px',
height: '200px'
});
$(this).find("img").delay(delay).animate({
marginTop: '+=5px',
marginLeft: '+=5px'
});
}, function () {
$(this).css("background-color", "#fff");
$(this).delay(delay).animate({
width: '300px',
height: '50px'
});
$(this).find("img").delay(delay).animate({
marginTop: '-=5px',
marginLeft: '-=5px'
});
});
});
So in a nutshell:
简而言之:
- I want the divs to remain on place when a div gets expanded
- I want that if the mouse remains 0.5 seconds on the div
.user
then the div should be expanded else nothing should happen.
当div扩展时,我希望div保持不变
我希望如果鼠标在div .user上保持0.5秒,那么div应该被扩展,否则什么都不应该发生。
1 个解决方案
#1
3
This can be done purely in CSS3, and here's what you're looking for: Wrap each <div class="user">
in a <div class="userWrap">
. Then, use the following CSS:
这可以完全在CSS3中完成,这就是你要找的东西:在
.userWrap {
position: relative;
display: inline-block;
width: 300px;
height: 50px;
overflow: visible;
z-index: 1;
}
.userWrap:hover {
z-index: 2;
}
.user {
position: absolute;
width: 300px;
height: 50px;
margin-bottom: 5px;
background: #fff;
transition: width 0.3s, height 0.3s;
}
.user:hover {
width: 350px;
height: 200px;
background: #eee;
transition: width 0.3s ease 0.5s, height 0.3s ease 0.5s;
}
To achieve the desired effect.
达到预期的效果。
在这里看一个演示。
#1
3
This can be done purely in CSS3, and here's what you're looking for: Wrap each <div class="user">
in a <div class="userWrap">
. Then, use the following CSS:
这可以完全在CSS3中完成,这就是你要找的东西:在
.userWrap {
position: relative;
display: inline-block;
width: 300px;
height: 50px;
overflow: visible;
z-index: 1;
}
.userWrap:hover {
z-index: 2;
}
.user {
position: absolute;
width: 300px;
height: 50px;
margin-bottom: 5px;
background: #fff;
transition: width 0.3s, height 0.3s;
}
.user:hover {
width: 350px;
height: 200px;
background: #eee;
transition: width 0.3s ease 0.5s, height 0.3s ease 0.5s;
}
To achieve the desired effect.
达到预期的效果。
在这里看一个演示。