Can Twitter Bootstrap alerts fade in as well as out?

前端 未结 10 492
夕颜
夕颜 2020-12-07 09:28

When I first saw the alerts in Bootstrap I thought they would behave like the modal window does, dropping down or fading in, and then fading out when closed. But it seems li

10条回答
  •  青春惊慌失措
    2020-12-07 10:25

    You can fade-in a box using jquery. Use bootstraps built in 'hide' class to effectively set display:none on the div element:

    ×

    Well done! You successfully read this alert message.

    and then use the fadeIn function in jquery, like so:

    $("#saveAlert").fadeIn();
    

    There are also specify a duration for the fadeIn function, e.g: $("#saveAlert").fadeIn(400);

    Full details on using the fadeIn function can be found on the official jQuery documentation site: http://api.jquery.com/fadeIn/

    Just a sidenote as well, if you arent using jquery, you can either add the 'hide' class to your own CSS file, or just add this to your div:

     

    Your div will then basically be set to hidden as default, and then jQuery will perform the fadeIn action, forcing the div to be displayed.

提交回复
热议问题