Override parent background color to none in nested Divs
Posted: 06 Jan 2015, 07:38
I have a parent Div and another Div inside, as child element.
The parent Div has set a background-color property, and i want to have the child Div without background-color. I set background-color: none; for the child Div, but it doesn't work, it still inherits the background-color of the parent element.
This is the css and html code:
Why then is the parent color not overridden?
The parent Div has set a background-color property, and i want to have the child Div without background-color. I set background-color: none; for the child Div, but it doesn't work, it still inherits the background-color of the parent element.
This is the css and html code:
Code: Select all
<style>
#parent {
position: relative;
width: 80%;
height: 200px;
background-color: #bbccfe;
}
#child {
margin: 5px auto;
width: 75%;
height: 90%;
background-color: none;
border: 2px solid #f00;
}
</style>
<div id="parent">Parent Div
<div id="child">Child Div</div>
</div>