加载时,网站可以在确定的div中启动?

问题描述:

加载时,网站可以在确定的div中启动? 我制作了this这样的三个div。
我想在网站加载时启动第二个div。 我该怎么做?加载时,网站可以在确定的div中启动?

html,body { 
 
    height:100%; 
 
    margin:0; 
 
} 
 

 
.content { 
 
    height:100%; 
 
    min-height:100%; 
 
} 
 

 
html>body .content { 
 
    height:auto; 
 
} 
 

 
#one { 
 
    background: #ff4444; 
 
} 
 

 
#two { 
 
    background: #ff5555; 
 
} 
 

 
#three { 
 
    background: #ff6666; 
 
}
<div class='content' id='one'></div> 
 
<div class='content' id='two'></div> 
 
<div class='content' id='three'></div>

+0

1)您可以更改divs的顺序。 2.)你可以使用js/jQuery使用'scrollTop'来显示div。等 – Jai

+0

当网站加载我想看到第二个div,那么它可以向下滚动或顶部看到其他人 – jorgebmx

你可以用流畅的动画滚动到使用animate股利:

$('html,body').animate({ 
    scrollTop: $("#two").offset().top 
}, 'slow'); 

Demo

编辑

没有动画:

document.location.href="#two"; 

Demo

+0

是可以做到没有动画?因为在这两个代码示例中,我看到网站如何滚动下来 – jorgebmx

+0

@jorgebmx请检查更新的答案 – Tushar

你需要在URL中使用#two(第二DIV的ID)。

this

使用此滚动第二个div眼帘负载:

$(function() { 
    $("#two")[0].scrollIntoView(); 
});