jeudi 22 octobre 2015

CSS display parent element's background-color on top of that of the child?

The following code displays the parent text on top of the child element but not the background color :

*{
    -webkit-box-sizing:border-box;
    box-sizing:border-box;
    perspective:1000px;
    -webkit-perspective:1000px;
}
.maindiv{
    color:black;
    width:80%;
    height:50px;
    margin:10px;
    flex-wrap:nowrap;
    position:absolute;
    z-index: 10;

}

.maindiv .facebook{
    background-color:red;
    display:block;
    position:relative;
}
.facebook:before{
    display:block;
    background-color:black;
    color:white;
    content:"Hover"; 
}
a{
    z-index:-999; 
    display:block;
    background-color:burlywood;
    text-decoration:none;
    color:black;
    font-size:larger;
    font-family:cursive;
    position:relative;
    height:33px;
    top:-40px; 
}
<!DOCTYPE html>
<html>
<head>
    <title></title>
        <meta charset="utf-8" />
    <link rel="stylesheet" href="codecss.css" />
</head>
<body>
    <div class="maindiv">
        <div class="facebook">Facebook
            <a href="http://www.facebook.com">Facebook</a>
        </div>
    </div>
</body>
</html>

, I've seen many answers here relating to this problem but none of them work and almost all of them are asking about background image I don't know if it makes any difference "




Aucun commentaire:

Enregistrer un commentaire