jquery slidedown on page load

╄→尐↘猪︶ㄣ 提交于 2020-01-24 09:48:04

问题


How can slide down a div with jquery on page load where css is set to display:none? I see a lot of solutions but none can slide div if css is set display:none. The best way is to hide it on load and after slidedown but the div have flash (show) when page is loading.


回答1:


You could try this:

$(document).ready(function(){
    $('.hidden').slideDown(1000);
});

HTML:

<div class="hidden">This is the content</div>

CSS:

.hidden{
 display:none;   
}

It slides down on page load.

DEMO




回答2:


$('#hidden_div_id').slideDown('slow');

this internally make use of display:block




回答3:


I didn't found above as working solution. So here it is http://www.robertprice.co.uk/robblog/using-jquery-to-scroll-to-an-element/

$('html, body').animate({
    scrollTop: ($('#element').offset().top)
},500);


来源:https://stackoverflow.com/questions/8702912/jquery-slidedown-on-page-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!