From bcd65bd164b78fcbd1437faf94eca8a971cb3787 Mon Sep 17 00:00:00 2001 From: ken Date: Tue, 29 Jul 2025 20:57:29 +0800 Subject: [PATCH] 'menu' --- assets/javascripts/app.js | 29 +++++++++++++++++-- assets/stylesheets/template/RWD.scss | 1 - .../stylesheets/template/layout/header.scss | 3 ++ assets/stylesheets/template/modules/menu.scss | 23 ++++++++++----- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js index 79e0b30..aae2ea8 100644 --- a/assets/javascripts/app.js +++ b/assets/javascripts/app.js @@ -1137,9 +1137,9 @@ $(document).ready(function () { $('.searchclass').appendTo('.header-nav'); } } else { - if (!$('.navbar-header .searchclass').length) { + $('.navbar-brand').after($('.searchclass')); - } + } } @@ -1569,6 +1569,31 @@ $(document).ready(function () { $(this).find('span').text(selectedText + '(已選取)'); }); }); +//選單li加上fa-chevron-down +$(document).ready(function () { + function addDropdownIcons() { + if ($(window).width() > 769) { + $('#main-nav.modules-menu-level-0 > li').each(function () { + if ($(this).children('ul').length > 0) { + const $toggle = $(this).children('a.dropdown-toggle'); + if ($toggle.find('i.fa-chevron-down').length === 0) { + $toggle.append(' '); + } + } + }); + }else { + // 螢幕寬度小於等於 768 時,移除所有 chevron-down icon + $('#main-nav.modules-menu-level-0 .kenmenu-drop').remove(); + } + } + + addDropdownIcons(); + + $(window).resize(function () { + addDropdownIcons(); + }); +}); + // //選單樣式2 // $(document).ready(function() { // "use strict"; diff --git a/assets/stylesheets/template/RWD.scss b/assets/stylesheets/template/RWD.scss index 6ecaa77..fbfba95 100644 --- a/assets/stylesheets/template/RWD.scss +++ b/assets/stylesheets/template/RWD.scss @@ -7,7 +7,6 @@ } @media(max-width: 767px) { .modules-menu .modules-menu-level-0>li { margin: 0; } - .modules-menu .modules-menu-level-0>li:hover { background: transparent; } } @media(max-width: $screen-xs) { diff --git a/assets/stylesheets/template/layout/header.scss b/assets/stylesheets/template/layout/header.scss index 66b2eaa..fca722f 100644 --- a/assets/stylesheets/template/layout/header.scss +++ b/assets/stylesheets/template/layout/header.scss @@ -8,6 +8,9 @@ background-color: #fff; position: relative; padding:0; + @media(max-width:768px){ + padding: 0.5em 0; + } } .header-nav { display: flex !important; diff --git a/assets/stylesheets/template/modules/menu.scss b/assets/stylesheets/template/modules/menu.scss index ee27b02..37bd788 100644 --- a/assets/stylesheets/template/modules/menu.scss +++ b/assets/stylesheets/template/modules/menu.scss @@ -165,11 +165,14 @@ -.modules-menu{ +#layout-navigation{ background-color: $theme-color-second; // border-top: 5px solid #9f9f9fcc; } - +.kenmenu-drop{ + padding-left: 0.5em; + font-size: small; +} #layout-navigation{ @media(min-width: 769px){ @@ -249,7 +252,7 @@ border-radius: 0.13em; top: 2em; @media(max-width: 769px){ - top: 1em; + top: 0.5em; font-size: 1em; } } @@ -266,14 +269,15 @@ list-style: none; position:relative; margin: 0; - padding: 0.5em; - border-bottom: 0.0625em solid lighten($theme-gray, 5%); + padding:0; + // border-bottom: 0.0625em solid lighten($theme-gray, 5%); & > a { display: block; padding: 1em; font-family: $main-font; font-size: 1.1em; + color: #fff; &:after{ content:''; position:absolute; @@ -291,7 +295,7 @@ bottom:0; } &.active { - color: $theme-color-second; + color: #fff; background: none; &:after{ width:100%; @@ -301,9 +305,9 @@ } &:hover { + background: rgba(darken($theme-color-second, 10%), 1); & > a { // color: $theme-color-second; - background: rgba(darken($theme-color-second, 10%), 1); box-shadow:none; &:after{ width:100%; @@ -531,10 +535,13 @@ width: 80%; position: absolute; right: 0; - background: #ffffff; + background:$theme-color-second; height: 100%; top: 0; padding-top: 40px; + color: #fff; + padding-left: 0; + padding-right: 0; } .modules-menu .modules-menu-level-0 > li > a, .modules-menu .modules-menu-level-0 ,.modules-menu .modules-menu-level-0 > li { font-weight:bold;