Skip to content

Commit 79e7280

Browse files
authored
offsets change | add exclamation mark
1 parent ee268a6 commit 79e7280

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

temp.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ var il = itemsall.length;
33
var vw = window.innerWidth;
44

55
for (var i=0; i < il; i++) {
6-
if (itemsall[i].offsetWidth > vw) {
7-
console.log(itemsall[i]);
6+
var offset = itemsall[i].getBoundingClientRect();
7+
if (offset.width > vw) {
88
itemsall[i].setAttribute("style", "border: 2px dashed red");
9-
var topOffset = itemsall[i].getBoundingClientRect().top;
10-
addOverflowWarning(itemsall[i],topOffset);
9+
addOverflowWarning(itemsall[i],offset.top);
1110
}
1211
};
1312

@@ -16,17 +15,19 @@ function addOverflowWarning(parent,offset) {
1615
var overflowWarning = document.createElement('span');
1716
overflowWarning.className= "overflowWarning";
1817

19-
overflowWarning.style.position = "fixed";
20-
overflowWarning.style.top = offset;
18+
overflowWarning.style.position = "absolute";
19+
overflowWarning.style.top = offset + "px";
2120
overflowWarning.style.right = "0";
2221

2322
overflowWarning.style.height = "0";
2423
overflowWarning.style.width = "0";
2524
overflowWarning.style.zIndex = "999";
2625

27-
overflowWarning.style.borderTop = "10px solid transparent";
26+
overflowWarning.style.borderTop = "15px solid transparent";
2827
overflowWarning.style.borderLeft = "30px solid red";
29-
overflowWarning.style.borderBottom = "10px solid transparent";
30-
28+
overflowWarning.style.borderBottom = "15px solid transparent";
29+
30+
overflowWarning.innerHTML = '<span style="position:absolute; color: #fff; left: -25px; top: -12px;"> ! </span>';
31+
3132
parent.appendChild(overflowWarning);
3233
}

0 commit comments

Comments
 (0)