为什么我不能在CSS中更改文本的颜色?

时间:2019-11-03 13:03:43

标签: html css frontend

我正在使用免责声明进行覆盖,并为其添加了样式。由于某些原因,p元素以不同的颜色显示。它将拒绝变为黑色。我该如何解决?

我已经尝试使用!importantopacity: 1;

@import url('https://fonts.googleapis.com/css?family=Poppins&display=swap');
@import url('https://fonts.googleapis.com/css?family=Asap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    height: 100vh;
}

.overlay {
    background: rgb(20, 20, 20);
    opacity: 0.4;
    height: 100%;
    align-items: center;
    justify-content: space-around;
    display: flex;
}

.disclaimer {
    background: white;
    opacity: 1 !important;
    width: 28%;
    height: 28%;
    align-items: center;
}

.heading-disclaimer {
    color: black !important;
    opacity: 1 !important;
    font-family: Poppins, sans-serif;
    width: 100%;
    z-index: auto;
    text-align: center;
}

.p-disclaimer {
    padding-top: 20px;
    font-size: 17px;
    z-index: auto;
    opacity: 1 !important;
    font-family: Asap;
    width: 100%;
    color: black !important;
    text-align: center;
}
<div class="overlay">
            <!-- Roblox Version -->
            <div class="disclaimer">
                <h1 class="heading-disclaimer">Disclaimer</h1>
                <p class="p-disclaimer">
                    Disclaimer!
                </p>
                <button class="ok">OK</button>
            </div>
</div>

我希望颜色为黑色,但是当我执行color: black;

时颜色不会改变

结果显示为灰色,可能与覆盖背景的颜色相同。

1 个答案:

答案 0 :(得分:1)

// *********************************** mouseEnter: function (e, obj) { console.log("mouse enter"); }, mouseLeave: function (e, obj) { console.log("mouse leave"); }, mouseDragEnter: function (e, node, prev) { console.log("mouse drag enter"); }, mouseDragLeave: function (e, node, next) { console.log("mouse drag leave"); }, mouseDrop: function (e, node) { console.log("mouse drag drop"); }, // ***********************************p的子元素,因此overlay是其父元素inherit的元素。您只需为此用途opacity更改父级opacity的{​​{1}}, 更改

background

rgba

.overlay {
    background: rgb(20, 20, 20);
    opacity: 0.4;
.overlay {
    background: rgba(20, 20, 20, 0.4);