-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathcss.priority.html
79 lines (78 loc) · 3.41 KB
/
css.priority.html
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Приоритет CSS селекторов</title>
<link rel="profile" href="https://gmpg.org/xfn/11"/>
<link rel="shortcut icon" href="https://anton.shevchuk.name/favicon.ico"/>
<link rel="stylesheet" href="css/styles.css"/>
<style>
#my:before {
content: '<article id="my" class="content">'
}
#id:before {
content: '<p id="id">'
}
button {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
text-align: left;
width: 100%;
}
</style>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/code.js"></script>
</head>
<body class="formatter">
<header>
<h1>Приоритет CSS селекторов</h1>
<h2>Попробуйте применить стили из меню справа</h2>
</header>
<main class="wrapper">
<article id="my" class="content">
<h3>Article Title</h3>
<p id="id">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus rutrum,
lectus eu varius consectetur, libero velit hendrerit augue, ut posuere enim neque
in libero. Donec eget sagittis nibh. Suspendisse sed tincidunt urna. Cras quis
euismod neque. Maecenas auctor ultricies posuere. Pellentesque luctus pulvinar dui
eget semper. Donec sodales odio eu sapien varius luctus. Donec dictum feugiat diam
at malesuada. Sed nec massa in augue condimentum faucibus quis ut diam. Quisque
nisl sem, semper nec vulputate vel, mattis sit amet justo. Aliquam purus felis,
tempor at scelerisque quis, tincidunt in neque. Etiam ut risus diam. Pellentesque
fermentum risus id elit feugiat cursus. Ut fringilla dictum diam, sed iaculis
lorem pulvinar ut. Cras vel elit id velit commodo viverra sit amet vel orci.</p>
</article>
</main>
<footer>
© <a href="https://anton.shevchuk.name/jquery-book/">jQuery for beginners</a>
</footer>
<aside>
<nav>
<a href="css.float.html" title="go prev" rel="prev">Prev</a>
<a href="index.html#0" title="back to Index" rel="index">Index</a>
<a href="css.selectors.html" title="go next" rel="next">Next</a>
</nav>
<hr/>
<h4>Шпаргалка по расчёту специфичности CSS селекторов</h4>
<code><em>// weight</em>
#id = [1,0,0]
.class = [0,1,0]
tag = [0,0,1]
<em>// compare</em>
[1,0,0] > [0,1,0] > [0,0,1]
[1,0,0] > [0,100,100]
[0,1,0] > [0,0,100]
</code>
<hr/>
<h4>Добавляем стили на страницу</h4>
<button type="button" data-style>p { color:orange }</button>
<button type="button" data-style>.content p { color:green }</button>
<button type="button" data-style>article.content p { color:blue }</button>
<button type="button" data-style>.wrapper .content p { color:red }</button>
<button type="button" data-style>#id { color:darkblue }</button>
<button type="button" data-style>#my p { color:darkcyan }</button>
<button type="button" data-style>#my #id { color:darkgreen }</button>
<button type="button" data-style>#my p#id { color:black }</button>
</aside>
</body>
</html>