Jquery 在浏览器中设置动画中心
我正在创建一个类似于TypeCode()的公文包部分。我有简单的jQuery动画,在单击时展开和收缩div。是否有一种方法可以在每次单击时将浏览器中的div集中起来,就像它们在TypeCode上那样Jquery 在浏览器中设置动画中心,jquery,animation,center,Jquery,Animation,Center,我正在创建一个类似于TypeCode()的公文包部分。我有简单的jQuery动画,在单击时展开和收缩div。是否有一种方法可以在每次单击时将浏览器中的div集中起来,就像它们在TypeCode上那样 // Select portfolio item var active = false; $('.portfolio-item').click(function(e) { // Check if alternative tab is open and then close it
// Select portfolio item
var active = false;
$('.portfolio-item').click(function(e) {
// Check if alternative tab is open and then close it
if ( $('#one').css("height") == "220px" ) {
$('#one').animate({
height: '110px',
}, 1000, function() {
// Animation complete
});
active = false;
}; // End if
if ( $('#two').css("height") == "220px" ) {
$('#two').animate({
height: '110px',
}, 1000, function() {
// Animation complete
});
active = false;
}; // End if
if (active == false) {
$('.portfolio-item').css("height", "110px");
$(this).animate({
height: '220px',
}, 1000, function() {
// Animation complete
});
active = true;
}; // End if
}); // End click function
// Close portfolio item
$('.close').click(function(e) {
e.stopPropagation();
$(this).parents('.portfolio-item').animate({
height: '110px',
}, 1000, function() {
});
active = false;
});
这里是基本的小提琴:
如您所见,如果您单击另一个选项卡(仅前两个),则当前选项卡将关闭,新选项卡将打开。这适用于少量内容,但对于较大的内容,显示效果不太好。
希望这会有所帮助非常感谢,这非常有帮助!
$('article').click(function(){
$(this).toggleClass('state-collapsed');
$('html,body').animate({scrollTop: $(this).offset().top}, 500);
});