2016년 1월 30일 토요일

[CSS] cascade



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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
    <head>
        <title>How CSS Rules Cascade</title>
        <style type="text/css">
            /*
             * : 모든 선택자로 우선순위가 낮다.
             */
            * {
                font-family: Arial, Verdana, sans-serif;}
            h1 {
                font-family: "Courier New", Courier, monospace;}
            /*
             Cascade : 뒤에있는 선택자로 덮어 써진다.
             */
            i {
                color: green;}
            i {
                color: red;}
            b {
                color: pink;}
            /*
             Cascade : 뒤에있는 선택자로 덮어 써지지 않기 위해서 !important를 추가한다.
             */
            p b {
                color: blue !important;}
            p b {
                color: violet;}
            /*
             #intro : 첫번째 p에만 적용
             */
            p#intro {
                font-size: 100%;}
            p {
                font-size: 50%;}
        </style>
    </head>
    <body>
        <h1>Potatoes</h1>
        <p id="intro">There are <i>dozens</i> of different <b>potato</b> varieties.</p>
        <p>They are usually described as early, second early and maincrop potatoes.</p>
    </body>
</html>
 
cs

댓글 없음:

댓글 쓰기