Check out the jsfiddle right here
I implemented a toggle effect on the box width using .animate()
Here's the HTML code:
<div id="box">
<div id="opener">Opener</div>
<div id="message">This is the message</div>
</div>
For the CSS:
#box {
position:fixed;
top: 20px;
left: 0;
width: 200px;
height: 400px;
}
#opener {
position: relative;
float: right;
right: 0;
top: 0;
width: 40px;
height: 40px;
background: #000;
overflow: hidden;
}
#message {
float: left;
overflow: hidden;
background: #f00;
width: 160px;
}
And for the jQuery part:
$(document).ready(function () {
$("#box").css("width", "40px");
$("#message").css("width", "0px");
var show = 0;
$("#opener").click(function () {
if (show === 0) {
$("#box").animate({
width: '200px'
});
$("#message").animate({
width: '160px'
});
show = 1;
} else {
$("#box").animate({
width: '40px'
});
$("#message").animate({
width: '0px'
});
show = 0;
}
});
});
You can easily make the jQuery more versatile by avoiding hard coded values.