引导表格不可点击

时间:2019-11-20 14:46:15

标签: bootstrap-4

您好,我试图弄清楚为什么此表格不可点击:

https://www.codeply.com/go/Am5LvvjTxC/bootstrap-4-center-form

这是HTML代码:

<section id="cover" class="min-vh-100">
    <div id="cover-caption">
        <div class="container">
            <div class="row text-white">
                <div class="col-xl-5 col-lg-6 col-md-8 col-sm-10 mx-auto text-center form p-4">
                    <h1 class="display-4 py-2 text-truncate">Center my form.</h1>
                    <div class="px-2">
                        <form action="" class="justify-content-center">
                            <div class="form-group">
                                <label class="sr-only">Name</label>
                                <input type="text" class="form-control" placeholder="Jane Doe">
                            </div>
                            <div class="form-group">
                                <label class="sr-only">Email</label>
                                <input type="text" class="form-control" placeholder="jane.doe@example.com">
                            </div>
                            <button type="submit" class="btn btn-primary btn-lg">Launch</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

这是CSS代码:

#cover {
    background: #222 url('https://thenypost.files.wordpress.com/2018/12/santa-claus-kids.jpg') center center no-repeat;
    background-size: cover;
    height: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    position: relative;
    z-index: -1;
}

#cover-caption {
    width: 100%;
    z-index: 1;
}


/* only used for background overlay not needed for centering */
form:before {
    content: '';
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
    background-color: rgba(0,0,0,0.3);
    z-index: -1;
}

form-z-index {
    z-index: 10;
}
}

我相信它可能是zindex。但是我找不到正确的顺序。有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

问题出在z-index(#cover上的-1):

将CSS更改为:

#cover {
    background: #222 url('https://unsplash.it/1920/1080/?random') center center no-repeat;
    background-size: cover;
    height: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    position: relative;
}

#cover-caption {
    width: 100%;
    position: relative;
    z-index: 1;
}

/* only used for background overlay not needed for centering */
form:before {
    content: '';
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
    background-color: rgba(0,0,0,0.3);
    z-index: -1;
}

这应该可以解决问题。

答案 1 :(得分:0)

cover-caption更改为position:relative ...

#cover {
    background: #222 url('https://unsplash.it/1920/1080/?random') center center no-repeat;
    background-size: cover;
    height: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    position: relative;
}

#cover-caption {
    width: 100%;
    position: relative;
    z-index: 1;
}

已修复:https://codeply.com/go/Am5LvvjTxC/bootstrap-4-center-form

相关问题