Skip to content Skip to sidebar Skip to footer

Css: How Do I Prevent The Background Color Of Div From Going Behind The Image It Is Sitting Above?

I have a div that I applied negative margins to so that it sits on top of an image. I also gave that div a background color. What happens is the text (of the div) is appearing abov

Solution 1:

Just assign position: relative; to the div.kid-text

Demo

div.kid-text {
    background: #FFFFFF;
    text-align: center;
    width: 150px;
    font-size: 20px;
    margin-top: -100px;
    position: relative;
    z-index: 999; /* Optional */
}

Also, you can use z-index: 999; to be safe...

Post a Comment for "Css: How Do I Prevent The Background Color Of Div From Going Behind The Image It Is Sitting Above?"