我正在尝试为wordpress创建一个主题,我正在尝试制作一个粘性标题但是粘性标题似乎不起作用,也许它是javascript。你能救我吗?
这是我的javascript:
Dim data() as string ' creates the untestable holder.
data = Split(vbNullString, ",") ' causes array to return ubound(data) = -1
If Ubound(data)=-1 then ' has no contents
' do something
End If
redim preserve data(Ubound(data)+1) ' works to increase array size regardless of it being empty or not.
data = Split(vbNullString, ",") ' MUST use this to clear the array again.
答案 0 :(得分:2)
创建一个固定类,下面的类将div修复到页面底部。你不会需要javascript,除非你打算打开和关闭固定类,然后你已经拥有的代码将通过Jquery addClass / removeClass来实现:
.fixed {
position: fixed !important;
top: auto !important;
bottom: 0 !important;
left: 0;
right: 0;
}
答案 1 :(得分:0)
请为您的标题尝试以下操作。 SCript文件:
// Create a clone of the menu, right next to original.
$('.topmenu').addClass('original').clone().insertAfter('.topmenu').addClass('cloned').css('position', 'fixed').css('top', '0').css('margin-top', '0').css('z-index', '500').removeClass('original').hide();
scrollIntervalID = setInterval(stickIt, 10);
function stickIt() {
var orgElementPos = $('.original').offset();
orgElementTop = orgElementPos.top;
if ($(window).scrollTop() >= (orgElementTop)) {
// scrolled past the original position; now only show the cloned, sticky element.
// Cloned element should always have same left position and width as original element.
orgElement = $('.original');
coordsOrgElement = orgElement.offset();
leftOrgElement = coordsOrgElement.left;
widthOrgElement = orgElement.css('width');
$('.cloned').css('left', leftOrgElement + 'px').css('top', 0).css('width', widthOrgElement).show();
$('.original').css('visibility', 'hidden');
} else {
// not scrolled past the menu; only show the original menu.
$('.cloned').hide();
$('.original').css('visibility', 'visible');
}
}
这对我有用