简体   繁体   English

轮廓线一半落后于背景色一半不

[英]outline half behind background-color half not

So I have some outlines on my divs which involves a mask. 因此,我的div上有一些轮廓,其中包括面罩。 but for some reason half the outline is behind the background-color, while other half isn't (see by clicking the second row). 但由于某种原因,轮廓的一半位于背景色的后面,而另一半则不在(请单击第二行)。

fiddle: https://jsfiddle.net/p08bc2bj/ 小提琴: https//jsfiddle.net/p08bc2bj/

HTML (ignore the vue stuff): HTML(忽略vue内容):

<div class='wrapper'>
     <div v-for="(card, index) in deck" class="row" @click="cardClicked(card)" tabindex="0">
        <div class="mana key">
            1
        </div>
        <div class="coin key">
            1
        </div>
        <div class="name">
            test
        </div>
        <div class="count">
            1
        </div>
        <div class=mask></div>
    </div>
    <div v-for="(card, index) in deck" class="row" @click="cardClicked(card)" tabindex="0">
        <div class="mana key">
            1
        </div>
        <div class="coin key">
            1
        </div>
        <div class="name">
            test
        </div>
        <div class="count">
            1
        </div>
        <div class=mask></div>
    </div>
    <div v-for="(card, index) in deck" class="row" @click="cardClicked(card)" tabindex="0">
        <div class="mana key">
            1
        </div>
        <div class="coin key">
            1
        </div>
        <div class="name">
            test
        </div>
        <div class="count">
            1
        </div>
        <div class=mask></div>
    </div>    
    <div v-for="(card, index) in deck" class="row" @click="cardClicked(card)" tabindex="0">
        <div class="mana key">
            1
        </div>
        <div class="coin key">
            1
        </div>
        <div class="name">
            test
        </div>
        <div class="count">
            1
        </div>
    </div>    
    <div v-for="(card, index) in deck" class="row" @click="cardClicked(card)" tabindex="0">
        <div class="mana key">
            2
        </div>
        <div class="coin key">
            2
        </div>
        <div class="name">
            test
        </div>
        <div class="count">
            2
        </div>
    </div>        
</div>

css: CSS:

.mask {
    background-color: rgba(0,0,0,0.6);
    height: 100%;
    position: absolute;
    width: 100%;
}

.row {
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    position: relative;

    &:focus {
        outline: red solid thick;
    }

    .name {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: keep-all;
        white-space: nowrap;
    }
    .key {
        display: inline-block;
        position: relative;
        text-align: center;
        width: 1.5em;
        &.coin {
            background-color: yellow;
        }
        &.mana {
            background-color: lightblue;
        }
    }

    &.used {
        background-color: rgba(0, 0, 0, 0.3);
    }
}

.wrapper {
    max-height: 100vh;
    overflow: auto;
}

If you want to see red line under mask, z-index:100; 如果要在遮罩下看到红线,则z-index:100; in mask . mask If else, z-index:100; 否则, z-index:100; in focus . focus

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

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