0

So I have a portfolio website. 6 squares which which are clickable. I want the site beneath the item that's is clicked to slide down and i want it to display details for this portfolio item in the space thats created by sliding down the content.

I want the effect described in the following link. But this is only working for one item. I've got 6. If item 1 is clicked, content slides down and you get details. What I want is when you click item 2, the details from item 1 slides back up and the details for item 2 slides down.

How to slide down a div then .fadeIn() the content and vice versa?

An example: http://www.applove.se Scroll down to the portfolio on this site and click on an item to see what I want to achieve.

This is my html. There is a UL above this, but for some reason when I copy it, the whole thing just gets messed up.

            <li class="port_list">
                <div id="port_img1"> intro_img1 </div>
            </li>

            <li class="port_list">
                <div id="port_img2"> intro_img2 </div>
            </li>   

            <li class="port_list">
                <div id="port_img3"> intro_img3 </div>
            </li>       

    </ul>

    <ul id="wrapper_portfolio">
            <li class="port_list">
                <div id="port_img4"> intro_img4 </div>
            </li>

            <li class="port_list">
                <div id="port_img5"> intro_img5 </div>
            </li>   

            <li class="port_list">
                <div id="port_img6"> intro_img6 </div>
            </li>       

    </ul>

CSS wil make sure that the first 3 li will display horizontal. The last three are also displayed horizontally beneath the first three. I am not working with images, but with background-images for every div.

EDIT:

Mike asked me to fiddle my html and css. Zo here it is. http://jsfiddle.net/StillD/bDMxs/

The pink boxes are my portfolio items. Beneath them I want to present detailed information (whole browser width) of the portfolio item you click. So when you click portfolio item 1, the 3 items (displayed horizontally) beneath it should slide down to make room for the details of portfolio item 1. If you click item 2, the details of item 1 should disappear to make room for the details of item 2, and so on.

(The details are represented by the picture of the bird for now).

Community
  • 1
  • 1
David Hakkert
  • 669
  • 3
  • 10
  • 25
  • this is trivial using jQuery and the `toggle` function. can you make a jsfiddle example or post some of your javascript? – Mike Corcoran Jun 07 '13 at 17:07
  • Hi. I actually can't find my javascript anymore which I used.... What I do know is that I used the javascript described in the link in my question. This is the HTML that I have. – David Hakkert Jun 07 '13 at 18:19
  • See my question, i edited it. – David Hakkert Jun 07 '13 at 18:23
  • well, if all of your `
      `'s have `id='wrapper_portfolio` - that is why your javascript only worked on the first `
        `. each id on each element on the page MUST be unique. when you use jQuery to select by id, it only grabs/returns the first matching element.
    – Mike Corcoran Jun 07 '13 at 18:27

1 Answers1

1

i think I understand what you want. here is a very simple jsfiddle example.

http://jsfiddle.net/yRcnz/1/

basically you will need some sort of element before each ul so the user has a place to click. once you have that area for a user to interact with, some simple javascript can toggle() the display of the ul elements.

$('.expandable-ul li').click(function() {
    $(this).children('img').toggle();
});

$('.expandable-ul img').toggle();
Mike Corcoran
  • 14,072
  • 4
  • 37
  • 49
  • You are getting really close! But i want the li's to be clickable
    intro_img4
    . And i want to slide down an image beneath it (not in the html though). Do you understand what I mean? I guess your solution will work, only i want the links that are clickable in your example to be displayed horizontal next to each other.
    – David Hakkert Jun 08 '13 at 08:12
  • Do you know how to achieve this? – David Hakkert Jun 08 '13 at 15:34
  • @user1737979 yeah, i gotcha. one sec and i'll update it to do what you want. – Mike Corcoran Jun 10 '13 at 15:32
  • @user1737979 i updated the fiddle. see if this does what you need. you could pretty easily further extend this to hide the parent
  • , and then show it again when the user clicks on the image to hide it.
  • – Mike Corcoran Jun 10 '13 at 15:49
  • I'm going to try this option! If it works i'll let you know! Thanks a lot for the help! – David Hakkert Jun 11 '13 at 18:20
  • Oeh, it's coming close to what I'm looking for. I tried to implement this, but there is a difference between my html/css and your fiddle: I am displaying the first 3 items horizontally. The second 3 items are also displayed horizontally, but beneath the first 3 items. This is the CSS I'm using: #wrapper_portfolio { position: relative; width: 900px; margin-left: auto; margin-right: auto; display: block; padding: 0 0 0 0; list-style: none; z-index: 10; top: 40px; } .port_list { position: relative; width: 300px; top: 27px; float: left; padding: 0 0 0 0; list-style: none; } – David Hakkert Jun 11 '13 at 18:30
  • if you get a small working example in a jsfiddle and include the link in your original post, i can help you more. it's hard for me to sort of guess at what will fix your issue without being able to look directly at your markup/css... – Mike Corcoran Jun 11 '13 at 18:31
  • Your fiddle does do the job, but it's pushing the bottom items to the right when you click (for example) the first item. When you click it, the image appears, but the 3 items beneath the first items are pushed to the right. – David Hakkert Jun 11 '13 at 18:32
  • I edited my original question and added a fiddle!! Hope you understand what I'm doing and that you can help me out. – David Hakkert Jun 11 '13 at 18:46
  • cool, i'll check it out in a few and try to get it to do what you want. – Mike Corcoran Jun 11 '13 at 19:24
  • Hi Mike, have you found the time already to check out my problem? I hope you could help me:) – David Hakkert Jun 13 '13 at 08:05