웹표준,웹접근성(html, html5, css, css3, javascript, jQuery, jQueryMobile, snecha, senchaTouch, php, mobileWebApp)

26. first-of-type - 자식 선택자 본문

css3/selector

26. first-of-type - 자식 선택자

jokack01 2013. 10. 1. 11:13

first-of-type - 자식 선택자

 : 부모로 부터 첫 번째 자식 요소 선택

 

ex) 모든 부모로 부터의 첫번째 p 인 요소를 선택 ( 예 : p:first-of-type )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>:first-of-type</title>
<style>
p:first-of-type
{
background:#ffff00;
}
</style>
</head>
<body>
     
    <h1>:first-of-type</h1>
     
    <h3>부모의 첫 번째 p 요소 인 모든 p 요소를 선택</h3>
    <p>body로 부터 첫번째 p </p>
    <p>body로 부터 두번째 p </p>
    <p>body로 부터 세번째 p </p>
     
    <div>
        <p>div로 부터 첫번째 p </p>
        <p>div로 부터 두번째 p </p>
        <p>div로 부터 세번째 p </p>   
    </div>
  
</body>
</html>

'css3 > selector' 카테고리의 다른 글

28. only-of-type - 자식 선택자  (0) 2013.10.01
27. last-of-type - 자식 선택자  (0) 2013.10.01
25.attribute*=value  (0) 2013.10.01
24. attribute$=value  (0) 2013.10.01
23.[attribute^=value] - 속성 값 선택자  (0) 2013.10.01