jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 如何在一个弹性框中褪色?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_197_1@在我淡入淡出之前,我该如何获得一个弹出框?我曾经用’display:0;’然后使用 jquery .fadeIn().但现在如果我将显示设置为0,当我淡入淡出时,当然我失去了盒子的弹性.如果我使用jquery将显示设置为flex,那么它只会出现,而不是淡入淡出.
<div class="" id="popupContainer">
<div class="flex-item-popup" id="popup">
    <div class="close"><i class="fa fa-2x fa-times-circle"></i></div>
    <h2></h2>
    <div class='text'></div>
    <div class="videos"></div>
    <div class="flex-container images"></div>
</div>
#popupContainer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display:flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    align-items: center;
    z-index: 15;
}

jQuery的:

$(document).ready(function() {
    //???
});

解决方法

这似乎有点奇怪,但你可以做的是在css中,设置为显示:none.那么诀窍就是把你的jquery中的显示设置为flex,然后再隐藏,然后fadeIn:

CSS:

#popupContainer {
    /* ... */

    display:none;
    flex-direction: row;
    flex-wrap: wrap;

    /* ... */
}

JS:

$("#popupContainer")
    .css("display","flex")
    .hide()
    .fadeIn();

是因为fadeIn()将项目设置回其以前的非隐藏显示值.所以设置flex和重新隐藏它将设置这个“认”为它被设置回.

http://jsfiddle.net/z2kxyjcq/1/

$("#popupContainer")
    .css("display","flex")
    .hide()
    .fadeIn(2000);
#popupContainer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display:none;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    align-items: center;
    z-index: 15;
    BACkground-color: red;
}
#popupContainer *{
    border: 1px solid blue;
BACkground-color: white;    
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="" id="popupContainer">
<div class="flex-item-popup" id="popup">
    <div class="close"><i class="fa fa-2x fa-times-circle">1</i></div>
    <h2>2</h2>
    <div class='text'>a</div>
    <div class="videos">b</div>
    <div class="flex-container images">c</div>
</div>

大佬总结

以上是大佬教程为你收集整理的jquery – 如何在一个弹性框中褪色?全部内容,希望文章能够帮你解决jquery – 如何在一个弹性框中褪色?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。