2013年12月15日星期日

About CSS child element selector



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
p>span{
color:green;
}
</style>
</head>

<body>
<p>这是最外层的文字,<span>这是中间层的文字,<b>这是最内层的文字,</b></span></p>
</body>
</html>


why even the sons of labels have been affected ? I wrote in Dreamweaver .
------ Solution ---------------------------------------- ----
this example there are issues now. It should be

which is the outermost text , This is a text in the middle layer , which is the innermost text , < ;/ p> This has the effect


outermost this text ,

intermediate layer which is a text , text which is innermost , < / span>


This has no effect.

b always inherited span style bar.

------ Solution ------------------------------------ --------
example of what is broken
certainly influenced , b inherited the span of color,

Reference : http://www.w3schools.com/cssref/pr_text_color.asp
inside Inherited: yes color refers to the value of this property is automatically inherited by the descendants
------ For reference only ------------------ ---------------------

------ For reference only ------------------------------- --------

--- --- For reference only ---------------------------------------
your text in the span inside, of course, affect the ah
------ For reference only ------------------------------ ---------

child element selector I read wrote only affect the direct descendants , will not affect the level of nested tags ah
------ For reference only ---------------------------------------
http://www .w3school.com.cn/css/css_selector_child.asp

your conceptual understanding is wrong ah

例如,如果您希望选择只作为 h1 元素子元素的 strong 元素,可以这样写:
h1 > strong {color:red;}
这个规则会把第一个 h1 下面的 strong 元素变为红色,但是第二个 strong 不受影响:
<h1>This is <strong>very</strong> important.</h1>
<h1>This is <em>really <strong>very</strong></em> important.</h1>

------ For reference only ----------------------------------- ----

<style>
    p>span{
        color:green;
    }//这话意思是不会影响第二个span的效果
</style>
</head>
 
<body>
    <p>这是最外层的文字,<span>这是中间层的文字,<b>这是最内层的文字,</b></span></p>
<p>这是最外层的文字,<b>这是最内层的文字<span>这是中间层的文字</b></span></p>
</body>

------ For reference only ---------------------------- -----------

------ For reference only ---------------------------------------

------ For reference only ---- -----------------------------------
you see people write p span and p> span , is not the same
------ For reference only --------------------------------- ------

this I know , but he p> after the span of this style , tag content not affected by the CSS style ?
------ For reference only -------------------------------------- -

and I follow his example exactly the same wrote , tag content is affected
------ For reference only ----- ----------------------------------
browser IE5, IE6, IE7, IE8, IE9 on CSS support the effect is not the same , you use the following IETester test versions display.
------ For reference only -------------------------------------- -

I am using Dreamweaver direct preview of it this is a few ?
------ For reference only ---------------------------------------

tried several a browser, anyway, is not what I try to see the effect of the example of this book , namely affected only the sub label , grandsons label unaffected.
------ For reference only ---------------------------------- -----

this book seems to be a problem !
------ For reference only ---------------------------------------

your second an example is not the effect is not because there is no direct child elements under

label label
------ For reference only -------------- -------------------------
landlord to change the code to change it came out with a changed
------ For reference only ------------------------------------ ---

is
------ For reference only --------------------------- ------------
you this is the most inner text included in , and has set up a text styles , that will certainly be affected ah
------ For reference only ------------------------------- --------
you remove

, plus direct test nested , part of the same style consistent with , not a child choice.

没有评论:

发表评论