简体   繁体   English

切换使用jQuery滑动div并将div推到新行

[英]Toggle slide out div with jQuery & push div onto new line

I'm having a small issue with a project i'm working on. 我正在处理的项目有一个小问题。

It's probably very simple but I'm not overly proficient with jquery and am having a few issues. 这可能很简单,但是我对jquery并不太熟练,并且遇到了一些问题。 I basically want to have a grid of 4 item rows, once a user clicks on a div, it slides out a bio the same width as the grid item (25%). 我基本上希望有一个包含4个项目行的网格,一旦用户单击div,它就会滑出与网格项目相同宽度的生物(25%)。 Then pushes the div beside it onto a new row. 然后将其旁边的div推到新行。

To give an idea, it's for an "our team" page, this page will display the photo of everyone in the grid and if they click the person it slides out their bio. 给出一个想法,它是针对“我们的团队”页面的,该页面将显示网格中每个人的照片,如果他们单击该人,它将滑出他们的生物。

Here is my code: 这是我的代码:

HTML 的HTML

<div class="team-list one-fourth nomargin">
     <div class="team-photo">
         <img class="front" src="{front_image}" alt="{title}" />
     </div>
     <div class="team-bio">
         team bio here
     </div>
</div>

CSS 的CSS

/* THE TEAM PAGE */
.team-list {
    position:relative;
}

.team-list .team-photo img {
    max-width:100%;
}

http://jsfiddle.net/7bJML/ http://jsfiddle.net/7bJML/

Many thanks for any help in advance! 非常感谢您的任何帮助!

As I understood you are looking something like this. 据我了解,您正在寻找类似的东西。 I hope it will help 希望对您有所帮助

Add this handler for sliding bio info: 添加此处理程序以获取滑动生物信息:

$('.team-photo').click(function() {
    $(this).next().slideToggle();
});

And CSS: 和CSS:

/* THE TEAM PAGE */
.team-list {
    position:relative;
    cursor: pointer
}

.team-list .team-photo img {
    max-width:100%;
}

.team-bio {
    display: none;
}

http://jsfiddle.net/QrfzA/ http://jsfiddle.net/QrfzA/

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

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