This commit is contained in:
parent
0b586b359b
commit
6b53c63c54
|
|
@ -32,59 +32,36 @@
|
|||
});
|
||||
});
|
||||
'use strict';
|
||||
$(document).ready(function() {
|
||||
// $('.orbit-bar-search-sign-language').before($('.header-nav blockquote'));
|
||||
$('.orbit-bar-search-sign-language').prepend($('.header-nav blockquote'));
|
||||
$('.header-nav #nfu_logo').appendTo('.orbit-bar-menu');
|
||||
// 確保兩個元素都存在
|
||||
// if ($('.header-nav blockquote').length && $('.orbit-bar-menu').length) {
|
||||
// $('.header-nav blockquote').appendTo('.orbit-bar-menu');
|
||||
// }
|
||||
function alignLogo(){
|
||||
//blockquote移動
|
||||
$(function() {
|
||||
// 1. 定義變數,減少重複選取 DOM 的效能消耗
|
||||
var $signLanguageBox = $('.orbit-bar-search-sign-language');
|
||||
var $headerNav = $('.header-nav');
|
||||
var $target = $('.header-nav blockquote');
|
||||
|
||||
var $brand = $('.navbar-brand');
|
||||
var $logo = $('#nfu_logo');
|
||||
|
||||
if(!$brand.length || !$logo.length) return;
|
||||
|
||||
if ($(window).width() >= 1420){
|
||||
|
||||
var left = $brand.offset().left;
|
||||
|
||||
$logo.css({
|
||||
position: 'absolute',
|
||||
left: left
|
||||
});
|
||||
function handleNavMove() {
|
||||
var windowWidth = window.innerWidth;
|
||||
|
||||
if (windowWidth > 768) {
|
||||
if ($signLanguageBox.length && $signLanguageBox.find('blockquote').length === 0) {
|
||||
$signLanguageBox.prepend($target);
|
||||
}
|
||||
} else {
|
||||
if ($headerNav.length && $headerNav.find('blockquote').length === 0) {
|
||||
$headerNav.append($target); // 或者用 .prepend() 取決於你要放的位置
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 初始執行一次
|
||||
handleNavMove();
|
||||
|
||||
function checkAlignLogo(){
|
||||
|
||||
if ($(window).width() >= 1420){
|
||||
alignLogo();
|
||||
} else {
|
||||
$('#nfu_logo').css({
|
||||
left: '',
|
||||
position: ''
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$(function(){
|
||||
|
||||
checkAlignLogo();
|
||||
|
||||
$(window).on('resize', function(){
|
||||
requestAnimationFrame(checkAlignLogo);
|
||||
// 監聽視窗縮放
|
||||
$(window).on('resize', function() {
|
||||
// 加上防抖 (Debounce) 可以讓效能更好,但若要即時反應可直接執行
|
||||
handleNavMove();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
//header fixed在上方
|
||||
function initdata1() {
|
||||
if ( $('.homebanner').length != 0) {
|
||||
|
|
|
|||
|
|
@ -47,9 +47,7 @@
|
|||
}
|
||||
}
|
||||
[accesskey="W"]{
|
||||
height: 40px;
|
||||
display: inline-block!important;
|
||||
line-height: 40px;
|
||||
float: left;
|
||||
color: #fff!important;
|
||||
@media(min-width:769px){
|
||||
|
|
|
|||
Loading…
Reference in New Issue