-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
131 lines (127 loc) · 2.74 KB
/
index.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Modify ::before and ::after Style</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style type="text/css">
body{
margin:0;
padding:0;
font-family:Verdana, Geneva, sans-serif;
font-size:13px;
}
.all{
padding:20px;
}
</style>
<style type="text/css" class="dynamicstyle">
.wrapper{
position:relative;
width:300px;
border:1px solid #999999;
margin-top:50px;
}
.container{
}
.wrapper::before{
content:"";
border:10px solid transparent;
border-bottom:10px solid #999999;
position:absolute;
left:50px;
top:-21px;
}
.container::before{
content:"";
border:10px solid transparent;
border-bottom:10px solid #FFFFFF;
position:absolute;
left:50px;
top:-20px;
}
.container p{
margin:0;
}
.container{
padding:16px;
}
.inner{
background-color:#FC0;
height:100px;
padding:20px;
}
</style>
<style type="text/css">
.container p{
margin:0;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor:default;
}
.container{
padding:24px;
}
.inner{
background-color:#FC0;
height:100px;
padding:20px;
}
</style>
<script type="text/javascript">
(function ($){
window.addRule = function(selector, styles, sheet) {
if (typeof styles !== "string"){
var clone = "";
for (var style in styles){
var val = styles[style];
style = style.replace(/([A-Z])/g, "-$1").toLowerCase(); // convert to dash-case
clone += style + ":" + (style === "content" ? '"' + val + '"' : val) + "; ";
}
styles = clone;
}
sheet = sheet || document.styleSheets[document.styleSheets.length-1];
if (sheet.insertRule) sheet.insertRule(selector + " {" + styles + "}", sheet.cssRules.length);
else if (sheet.addRule) sheet.addRule(selector, styles);
return this;
};
if ($){
$.fn.addRule = function (styles, sheet) {
addRule(this.selector, styles, sheet);
return this;
};
}
}(window.jQuery));
function setTrianglePosition(left, top)
{
$(".wrapper:before").addRule({
left: left+"px",
top: top+"px"
});
$(".container:before").addRule({
left: left+"px",
top: (top+1)+"px"
});
}
$(document).ready(function(e) {
$(document).on('click', '.inner', function(e){
var left = e.clientX;
setTrianglePosition(left-18, -21)
});
});
</script>
</head>
<body>
<div class="all">
<div class="wrapper">
<div class="container">
<div class="inner">
<p>Click anywhere on this area :)</p>
</div>
</div>
</div>
</div>
</body>
</html>