javascript - Showing and hiding a DIV partially - Stack Overflow

I need to hide a DIV partially, not totally. When page loads, I want it to show the first, let's s

I need to hide a DIV partially, not totally. When page loads, I want it to show the first, let's say, 100 pixels sitting on the uppermost part of the div. When the user clicks a certain button, the div will open (it could be a sliding effect like jQuery's show()). When the user clicks back the same button, the div will return to its original state showing only the top 100 pixels. I am trying to figure out how to do this with jQuery because it seems to be the best way to do that. Any hints? Thank you.

I need to hide a DIV partially, not totally. When page loads, I want it to show the first, let's say, 100 pixels sitting on the uppermost part of the div. When the user clicks a certain button, the div will open (it could be a sliding effect like jQuery's show()). When the user clicks back the same button, the div will return to its original state showing only the top 100 pixels. I am trying to figure out how to do this with jQuery because it seems to be the best way to do that. Any hints? Thank you.

Share Improve this question asked Jan 15, 2009 at 19:04 Marcos BuarqueMarcos Buarque 3,4288 gold badges46 silver badges47 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

it could be done by setting div's initial height to 100px and setting its overflow to hidden in CSS. then you can change div's height to auto when you show the full div on javascript button click.

example: http://www.quirksmode/css/overflow.html

CSS code:

overflow : hidden;

you will need the toggle method and some animation , jquery style :

set the height of the div to 10px with Css.

$("td").toggle(
  function () {
    $(this).animate( { height:"100px" } , 1000 )
  },
  function () {
     $(this).animate( { height:"10px" } , 1000 )
  }
);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744269050a4566008.html

相关推荐

  • javascript - Showing and hiding a DIV partially - Stack Overflow

    I need to hide a DIV partially, not totally. When page loads, I want it to show the first, let's s

    7天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信