m****r 发帖数: 7 | 1 Whenever I tried to nest an element in a div, the element does not inherit the
values of the div. For example:
In , I define:
.wrap {background-color: gray;}
.title {position: relative;
margin-top: 3px;
margin-left: 3px;
font-size: 30px;
float: left;}
Then in , I have:
wrap div
The Title of the Page
I place the "title" 3px from the top and 3px from the left of the containing
box "wrap", but the background color of the wra | v***n 发帖数: 53 | 2 seems has a higher priority and its bgcolor is default as white, if
you add background-color: gray; to .title it should be gray
the
title
able
【在 m****r 的大作中提到】 : Whenever I tried to nest an element in a div, the element does not inherit the : values of the div. For example: : In , I define: : .wrap {background-color: gray;} : .title {position: relative; : margin-top: 3px; : margin-left: 3px; : font-size: 30px; : float: left;} : Then in , I have:
| m****r 发帖数: 7 | 3 .title is a class name in style sheet, but not in html. Why does it
have a higher priority?
containing
【在 v***n 的大作中提到】 : seems has a higher priority and its bgcolor is default as white, if : you add background-color: gray; to .title it should be gray : : the : title : able
| v***n 发帖数: 53 | 4 inheritance applies only to foreground properties. Background properties do
not inherit. Instead, the default background of any element is transparent
unless the brower is specifically told otherwise. This means that the
background color or image properties of the containing element show through on
all its children unless otherwise specified.
if
inherit
background-color
box.)
【在 m****r 的大作中提到】 : .title is a class name in style sheet, but not in html. Why does it : have a higher priority? : : containing
|
|