Home  >  Article  >  Web Front-end  >  Does the background-color attribute have inheritance_html/css_WEB-ITnose

Does the background-color attribute have inheritance_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:40:362526browse

Is there inheritance for the background-color attribute:

Because the background of the object is transparent by default, if the parent object sets the background color, the child The object is also rendered with the background color of the parent object, as if the child object inherits the background color of the parent object, which is actually a visual error. Let's use an example to illustrate that background-color does not have inheritance.

Example code:

<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="author" content="http://www.51texiao.cn/" /><title>蚂蚁部落</title><style type="text/css"> .parent {   width:200px;   height:200px;   border:1px solid red;   background-color:green; } .children {   width:120px;   height:120px;   border:1px solid red;   position:relative;   left:150px; } </style> </head> <body>   <div class="parent">     <div class="children"></div>   </div> </body> </html>

The original address is: http://www.51texiao.cn/div_cssjiaocheng/2015/0507/904.html

The most original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=4647

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn