简体   繁体   中英

Show/hide effect for all list elements

I'm trying to build image gallery with folders. When user press on folder name it hides all the pictures and shows only pictures for this folder. I have managed to do it but when images are hiding or showing they change move to one column and then animate. How can I make them to stay in-line all the time?

$('#folderList li').click(function () {
    var folderToShow = $(this).attr('id');
    $('#galleryList li').hide("slide", {}, 1000);
    $('#galleryList li.' + folderToShow).show("slide", {}, 1000).css("display", "inline-block");
});

Example jsFiddle

Add a float property in your CSS

#galleryList ul li {
    display: inline-block;
    margin: 10px;
    float:left
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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