메뉴 위에 떠있는 표시기 설정이 있습니다. 문제는 누군가가 '표시가 같은 장소에 머문'크기를 조정할 때 페이지가 '올바르게 배치되도록 새로 고침'해야한다는 것입니다. 페이지 크기가 조정되는 것을 감지하면 페이지 자체를 새로 고치는 방법은 무엇입니까? 또는 더 좋은 방법이 있습니까? jQuery를jquery 크기를 조정할 때 페이지를 새로 고치는 방법?
function findPosY(b) {
var a = 0;
if (b.offsetParent) {
while (1) {
a += b.offsetTop;
if (!b.offsetParent) {
break
}
b = b.offsetParent
}
} else {
if (b.y) {
a += b.y
}
}
return a
}
function findPosX(b) {
var a = 0;
if (b.offsetParent) {
while (1) {
a += b.offsetLeft;
if (!b.offsetParent) {
break
}
b = b.offsetParent
}
} else {
if (b.x) {
a += b.x
}
}
return a
}
function setNotifications() {
$("#shortcut_notifications span").each(function() {
if ($(this).attr("rel") != "") {
target = $(this).attr("rel");
if ($("#" + target).length > 0) {
var a = findPosY(document.getElementById(target));
var b = findPosX(document.getElementById(target));
$(this).css("top", a - 31 + "px");//-24
$(this).css("left", b + 83 + "px")//+60
}
}
});
$("#shortcut_notifications").css("display", "block")
}
CSS
#shortcut_notifications {
display:none;
}
.notification {
color:#fff;
font-weight:700;
text-shadow:1px 0 0 #333;
background:transparent url(../images/bg_notification.png) no-repeat center;
position: absolute;/*absolute*/
width:37px;/*37*/
height:37px;
display:block;
text-align:center;
padding-top:17px;
color:#ffffff;
}
#nav li {
display:block;
float:right;
padding:19px 21px;
text-align: left;
position:relative;
height:24px;
font-size:16px;
}
HTML
<li class="settings"><a class="settings" href="#">Settings</a>
<ul>
<li><a href="#">Game Settings</a></li>
<li><a href="#">Transactions </a></li>
</ul>
</li>
뛰어난 아이디어. 그것은 작동합니다. 이걸 사용하겠습니다. 감사합니다. u 너무 많이 – Maju