简体   繁体   English

jQuery轻松插件

[英]JQuery Easing plugin

I would like to use JQuery easing to navigate to a named section in my page, and so far it works. 我想使用JQuery缓动导航到页面中的命名部分,到目前为止,它仍然有效。

In one of the sections, I have a form which I would like to have centered vertically and horizontally, so I placed it in a sub-div, and vertically/horizontally centered it. 在其中一个部分中,我有一个要垂直和水平居中的表格,因此我将其放在细分中,然后垂直/水平居中。

What I'm not sure how to do is to change the javascript so that when jumping to the form section, the form eases to the middle of the page. 我不确定该怎么做,就是更改javascript,以便在跳转到表单部分时,表单轻松到页面中间。

I am using the following code block: 我正在使用以下代码块:

$('.nav a').bind('click',function(event){

    var $anchor = $(this);

    $('html, body').stop().animate({
        scrollTop: $($anchor.attr('href')).offset().top
    }, 1500,'easeInOutExpo');

    event.preventDefault();
});    
       ​

Here's a JSFiddle of what I have, can any one please enlighten me? 这是我所拥有的JSFiddle,请问能启发我吗? Thanks! 谢谢!

http://jsfiddle.net/soraya_soch/LyDWH/ http://jsfiddle.net/soraya_soch/LyDWH/

[EDIT] [编辑]

My goal is when clicking on the link, that the page eases down and ceters the form's div. 我的目标是单击链接时,该页面可以简化并限制表单的div。 在此处输入图片说明

Check this out, it does not set form div to center vertically ,that's what help in achieving to set the desired output as in above image since there also vertival center is not given 进行检查,它不会将div设置为垂直居中,这有助于如上图所示设置所需的输出,因为没有给出垂直中心

http://jsfiddle.net/LyDWH/3/ http://jsfiddle.net/LyDWH/3/

Made minor changes in CSS and HTML page 在CSS和HTML页面中进行了较小的更改

div.cn {
    display: table-cell;
    width: 960px;
    height: 2000px;
    background: gray;
    text-align: center;
}

div.inner {
    display: inline-block;
    width: 200px;
    height: 200px;
    background: red;
    margin-top: 20%;
}
​

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM