0

I made an expandable div with jQuery so in my css the div is 250px width and when i expand it is animated to 500px.

How can i make it responsive? I mean when the div is "open" i want it so that when the user resizes his window the div resizes with it and also when the user clicks open on the div it opens depending within the window's size.

Here is my code:

$('.button').click(function(){

$('.content').animate({width: "500px",}, 500);
setTimeout(function(){
    $('.content').animate({top: "-400px", marginBottom: "0px", height:"1000px"}, 500);
},500);

});
.content{
	width:250px;
}

http://jsfiddle.net/Tibuakaw/of8znvc5/

2 Answers 2

1
.content{
    width:50%;
}

play around with the width :)

Sign up to request clarification or add additional context in comments.

2 Comments

actually i was thinking about make like 150% of the width into the javascript and like that make a media queries on the div like that the javascript properties take always 150% of the size but it' s really unstable :p
1

you need to use percentage instead of pixels when opening your div:

$('.content').animate({width: "80%",}, 500);

That will expand the div to be 80% the width of the page.

jsfiddle here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.