简体   繁体   English

使用Bootstrap的fadeIn面板

[英]fadeIn panel using Bootstrap

I would like to fadeIn a panel form that I've made in Bootstrap 3. I've tried different methods but I cannot figure it out. 我想淡入淡出在Bootstrap 3中制作的面板形式。我尝试了不同的方法,但无法弄清楚。

Here is the JSFiddle . 这是JSFiddle

This is my fade function: 这是我的淡入淡出功能:

$( document ).ready(function() {
    $( ".anim" ).fadeIn( "slow" );
});

You need to hide .anim in css so it can fade in. 您需要在CSS中隐藏.anim,以便它可以淡入。

.anim {
  display: none;
}

Could also do this 也可以做到这一点

add .anim {display:none} to the css then show it in 将.anim {display:none}添加到CSS,然后在其中显示

$( document ).ready(function() {
  $( ".anim" ).fadeIn( "slow" );
});

http://jsfiddle.net/1egdn3wx/1/ http://jsfiddle.net/1egdn3wx/1/

You have to consider that fadeIn method make the .anim elements opacity from the current to 1. So because the current opacity of .anim is 1, fadeIn() consider the fading done. 您必须考虑fadeIn方法使.anim元素的不透明度从当前变为1。因此,由于.anim的当前不透明度为1, fadeIn()考虑完成了衰落。

You should execute the hide() method before fadeIn . 您应该在fadeIn之前执行hide()方法。 So your script will become as follow. 因此,您的脚本将如下所示。

$( document ).ready(function() {
  $( ".anim" ).hide().fadeIn( "slow" );
});

Edit: this I've forked your fiddle with this working demo 编辑:这是我用这个工作演示分叉的小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM