Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing just some part of a div

Tags:

jquery

css

I want to have a div which is shown just top part of it (like 50px oh height) and other (bottom like 100px) part of the div should be shown by jquery.show() or something else. Is there anyone know how to do it ?

Here is an image to help explain

like image 826
Mtok Avatar asked Apr 16 '12 11:04

Mtok


1 Answers

You could set the div height to 50px fixed and on click you can change the height to auto per javascript/jQuery, or revert it from auto to 50px.

CSS:

.mydiv{
  height:50px;
  min-height:50px;
  overflow:hidden;
}

jQuery:

$("document").ready(function(){
  $(".mydiv").click(function(){
    if($(".mydiv").css("height")!="50px"){
      $(".mydiv").slideDown();
    }
    else{
      $(".mydiv").slideUp();
    }
  }
}
like image 196
Sven Bieder Avatar answered Sep 30 '22 11:09

Sven Bieder