-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcss-after-before-Selector.css
81 lines (79 loc) · 1.81 KB
/
css-after-before-Selector.css
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
80
81
div {
border: solid 1px black;
padding: 5px;
text-align: center;
/* display: table; */
/* display: inline-block; */
}
div:before {
content: "Added BEFORE anything within the div! ";
color: red;
}
div:after {
content: "Added AFTER anything within the div!";
color: green;
}
/* before & :after are used to apply css properties JUST before/after the content WITHIN the matching element. */
p::before {
content: "Read this -";
background-color: yellow;
color: red;
font-weight: bold;
}
p::after {
content: " - Remember this";
background-color: yellow;
color: red;
font-weight: bold;
}
/*
The ::before selector inserts something before the content of each selected element(s).
The ::after selector inserts something after the content of each selected element(s).
*/
/* a:after {
color: #9799a7;
content: " (" attr(href) ")";
font-size: 11px;
} */
.arrow {
color: whitesmoke;
text-decoration: none;
background-color: royalblue;
display: inline-block; /*to make 'a tag' behaving like block element*/
height: 1.88rem;
line-height: 1.88rem;
/* same value line-height and height to make single text line vertically center */
padding: 0 0.8rem;
margin-left: 20rem;
position: relative;
}
.arrow::before,
.arrow::after {
content: "";
height: 0;
position: absolute;
width: 0;
}
.arrow::before {
border-bottom: 15px solid royalblue;
border-left: 15px solid transparent;
border-top: 15px solid royalblue;
left: -15px;
}
.arrow::after {
border-bottom: 15px solid transparent;
border-left: 15px solid royalblue;
border-top: 15px solid transparent;
right: -15px;
}
.arrow:hover {
color: wheat;
background-color: tomato;
}
.arrow:hover::before {
border-top: 15px solid tomato;
border-bottom: 15px solid tomato;
}
.arrow:hover::after {
border-left: 15px solid tomato;
}