Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 需要帮忙把我的同位素容器放在中心吗_Jquery_Css_Wordpress_Jquery Isotope - Fatal编程技术网

Jquery 需要帮忙把我的同位素容器放在中心吗

Jquery 需要帮忙把我的同位素容器放在中心吗,jquery,css,wordpress,jquery-isotope,Jquery,Css,Wordpress,Jquery Isotope,我有一组缩略图,我想在柱下降时居中,有没有一种简单的方法可以做到这一点 这是一个例子 这是jquery function initIsotope() { // Init Portfolio masonry var $container = $('.portfolio-container'); $container.isotope({ resizable: false, masonry: { columnWidth:

我有一组缩略图,我想在柱下降时居中,有没有一种简单的方法可以做到这一点

这是一个例子

这是jquery

function initIsotope() {
    // Init Portfolio masonry
    var $container = $('.portfolio-container');
    $container.isotope({
        resizable: false,
        masonry: {
            columnWidth: 291,
            gutterWidth: 10
        }
    });

    $(".filter-portfolio li a").click(function(e){
        e.preventDefault();
        $(this).closest('.filters').find('a').removeClass('selected');
        $(this).toggleClass('selected');


        var selector = $(this).attr('data-filter');
        $('.portfolio-container').isotope({
            filter: selector,
            masonry: {
                columnWidth: 291,
                gutterWidth: 10
            }
        }, function() {
            // Refresh waypoints
            $.waypoints('refresh');
        });

        return false;
    });

  $('.noclick').off('click');

    // Init Portfolio masonry
    $('.entries-container').isotope({
        itemSelector : '.blog-entry'
    });
}

function reLayoutIsotope() {
    $('.isotope').isotope( 'reLayout' );
}

你有权访问css吗?它们有确切的宽度或百分比吗? 如果你有一个围着他们的人,你可以确定他们的绝对位置。然后,给容器一个宽度(任何都可以)。将容器放置在宽度的负一半。然后给它留50%的余量;下面的例子

Html

这将使容器从页面左侧移动50%。然后,它会将其移回容器一半宽度的左侧。将元素的中间与页面的中间对齐


希望它有帮助。

如果你想让它成为屏幕的死角,请使用如下css:

.portfolio-container {
    display: block;
    position: relative;
    margin: 0 auto;
    width: 1000px; /* change this to how large you want it to be width-wise */
}
.container {position:absolute; left:-300px; width:600px; margin-left:50%;}
.portfolio-container {
    display: block;
    position: relative;
    margin: 0 auto;
    width: 1000px; /* change this to how large you want it to be width-wise */
}