36
个编辑
-
汇聚密码安全智慧 共享实战经验!
无编辑摘要 标签:已被回退 移动版编辑 移动版网页编辑 |
无编辑摘要 标签:已被回退 |
||
| 第53行: | 第53行: | ||
}); | }); | ||
// 设置每个 li | // 设置每个 li 的宽度和样式(防止换行) | ||
lis.css({ | lis.each(function() { | ||
var $li = $(this); | |||
// 先设置宽度,确保不换行 | |||
$li.css({ | |||
'width': containerWidth + 'px', | |||
'height': '25px', | |||
'line-height': '25px', | |||
'list-style': 'none', | |||
'float': 'left', | |||
'display': 'inline-block', | |||
'box-sizing': 'border-box', | |||
'padding': '0 10px', | |||
'vertical-align': 'top', | |||
'flex-shrink': '0', | |||
'white-space': 'nowrap', | |||
'overflow': 'hidden', | |||
'text-overflow': 'ellipsis', | |||
'text-align': 'center' | |||
}); | |||
}); | }); | ||
| 第142行: | 第150行: | ||
var totalWidth = containerWidth * lis.length; | var totalWidth = containerWidth * lis.length; | ||
ul.css('width', totalWidth + 'px'); | ul.css('width', totalWidth + 'px'); | ||
lis.css('width' | lis.each(function() { | ||
$(this).css({ | |||
'width': containerWidth + 'px', | |||
'white-space': 'nowrap', | |||
'overflow': 'hidden', | |||
'text-overflow': 'ellipsis', | |||
'text-align': 'center' | |||
}); | |||
}); | |||
var currentLeft = parseInt(ul[0].dataset.left) || 0; | var currentLeft = parseInt(ul[0].dataset.left) || 0; | ||
| 第218行: | 第234行: | ||
var promptAdded = initUserPrompt(); | var promptAdded = initUserPrompt(); | ||
// 延迟初始化滚动效果,确保 DOM | // 延迟初始化滚动效果,确保 DOM 完全更新和样式应用 | ||
setTimeout(function() { | setTimeout(function() { | ||
// 再次确保所有 li 都有正确的样式(防止换行) | |||
var siteNoticeScroll = $('#siteNoticeScroll'); | |||
if (siteNoticeScroll.length) { | |||
var ul = siteNoticeScroll.find('ul:first'); | |||
if (ul.length) { | |||
var lis = ul.find('li'); | |||
var containerWidth = siteNoticeScroll.width() || siteNoticeScroll[0].offsetWidth || siteNoticeScroll[0].clientWidth; | |||
if (containerWidth > 0) { | |||
lis.each(function() { | |||
var $li = $(this); | |||
$li.css({ | |||
'white-space': 'nowrap', | |||
'overflow': 'hidden', | |||
'text-overflow': 'ellipsis', | |||
'text-align': 'center' | |||
}); | |||
}); | |||
} | |||
} | |||
} | |||
initSiteNoticeScroll(); | initSiteNoticeScroll(); | ||
}, promptAdded ? 100 | }, promptAdded ? 200 : 100); | ||
} | } | ||