nickruggiero
nickruggiero

Reputation: 161

Div Expandsion on Click

I was wondering if anyone can give me some insight on javascript/jquery for div expansion. In the JSFiddle you will find:

So my question is:

What can I use so that when a div is clicked, it expands to the size of the four divs (289 X 289)?

The expanded div will then be filled with unique content.

Thank you!

JSFiddle: http://jsfiddle.net/SXfeG/1/

Upvotes: 1

Views: 151

Answers (1)

Holt
Holt

Reputation: 37606

If you use absolute positionning, you can add some CSS like that :

.div-clicked {
    width: 289px !important ;
    height: 289px !important ;
    margin-top: 0 !important ;
    margin-left: 0 !important ;
    z-index: 400 ;
}

div {
    transition: all 1s ; // To add transition effect
}

And then, with jQuery, you can toggle 'clicked' class simply by using :

$('div').on('click', function (e) { $(this).toggleClass('clicked') ; })

JSFiddle : http://jsfiddle.net/85QFN/

Upvotes: 4

Related Questions