You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* a dica de ferramenta deve funcionar após a rolagem da página também */
9
+
}
10
+
.tooltip {
11
+
position: fixed;
12
+
z-index:100;
13
+
padding:10px20px;
14
+
border:1px solid #b3c9ce;
15
+
border-radius:4px;
16
+
text-align: center;
17
+
font: italic 14px/1.3 sans-serif;
18
+
color:#333;
19
+
background:#fff;
20
+
box-shadow:3px3px3pxrgba(0,0,0,.3);
21
+
}
22
+
#house {
23
+
margin-top:50px;
24
+
width:400px;
25
+
border:1px solid brown;
26
+
}
27
+
#roof {
28
+
width:0;
29
+
height:0;
30
+
border-left:200px solid transparent;
31
+
border-right:200px solid transparent;
32
+
border-bottom:20px solid brown;
33
+
margin-top:-20px;
34
+
}
35
+
p {
36
+
text-align: justify;
37
+
margin:10px3px;
38
+
}
39
+
</style>
40
+
</head>
41
+
<body>
42
+
43
+
<divdata-tooltip="Here is the house interior" id="house">
44
+
<divdata-tooltip="Here is the roof" id="roof"></div>
45
+
<p>Once upon a time there was a mother pig who had three little pigs.</p>
46
+
<p>The three little pigs grew so big that their mother said to them, "You are too big to live here any longer. You must go and build houses for yourselves. But take care that the wolf does not catch you."</p>
47
+
<p>The three little pigs set off. "We will take care that the wolf does not catch us," they said.</p>
48
+
<p>Soon they met a man.
49
+
<ahref="https://en.wikipedia.org/wiki/The_Three_Little_Pigs" data-tooltip="Read on…">Hover over me</a>
50
+
</p>
51
+
52
+
</div>
53
+
54
+
<scripttype="text/javascript">
55
+
/**
56
+
* Escreva JavaScript que mostre uma dica de ferramenta sobre um elemento com o atributo data-tooltip. O valor desse atributo deve se tornar o texto da dica de ferramenta.
57
+
*
58
+
* É como o comportamento da dica de ferramenta da tarefa , mas aqui os elementos anotados podem ser aninhados. A dica de ferramenta mais profundamente aninhada é mostrada.
59
+
*
60
+
* Apenas uma dica de ferramenta pode aparecer ao mesmo tempo.
61
+
*
62
+
* Por exemplo:
63
+
*/
64
+
65
+
lethouse=document.querySelector("#house");
66
+
67
+
functioncenter(elem,tooltip){
68
+
letdif=0,deslo=0;
69
+
//verifica coordenadas de deslocamento para centralizar
70
+
//centralizar tooltip em relação a elem
71
+
if(elem.offsetWidth>tooltip.offsetWidth){
72
+
dif=elem.offsetWidth-tooltip.offsetWidth;
73
+
deslo=dif/2;
74
+
tooltip.style.left=deslo+"px";
75
+
}else{
76
+
//centraliza tooltip em relação a elem mesmo elem sendo menor
0 commit comments