模板:meiyi | 250603
效果:
HTML:
<div class="container-fluid header">
<div class="container-xxl">
<div class="row justify-content-lg-between align-items-center">
<div class="logo d-xl-none">$show_logo$</div>
<div class="menu d-none d-xl-flex" id="navbar">$func_menu(pos=0,sub=2,divi=none)$</div>
<navbar-toggler class="fixed-top text-right mt-3" btn="bg-fst white m-3 mt-4 d-inline-block d-xl-none"
tar="navbar" menu="bg-fst px-0 red li-hover-sec hover-white ul-li-2" show="false"></navbar-toggler>
</div>
</div>
</div>
CSS:
.Logo {
display: flex;
flex-flow: column-reverse wrap;
margin-bottom: 1rem;
.dt {
font-size: 2rem;
}
.dd {
img {
max-width: 100%;
filter: brightness(100%);
}
}
}
li.logo {
flex-grow: 1;
flex-shrink: 0;
flex-basis: auto;
.Logo {
img {
max-height: 60px !important;
width: auto !important;
max-width: auto !important;
}
}
}
.header {
background-color: rgba($color: white, $alpha: 0.5);
.menu {
display: flex;
flex-grow: 1;
ul {
flex-grow: 1;
li {
padding-left: 20px;
padding-right: 20px;
position: relative;
a {
padding-top: 10px;
padding-bottom: 10px;
}
ul {
position: absolute;
background-color: rgba($color: white, $alpha: 0.5);
padding-top: 10px !important;
padding-bottom: 0 !important;
top: 100% !important;
left: 50% !important;
transform: translateX(-50%);
z-index: 10000;
li {
padding: 0;
a {
font-weight: 100 !important;
padding: 10px 15px;
}
ul {
display: none !important;
}
&:last-child {
border-bottom: 0;
}
&:hover {
background-color: darken($fst, 5%) !important;
a {
color: white !important;
}
ul {
display: flex !important;
position: absolute;
top: 0 !important;
left: 150% !important;
padding: 0 !important;
background-color: $fst;
li {
border-bottom: 1px solid rgba($color: white, $alpha: 0.1);
&:hover {
background-color: #2D3D87 !important;
}
}
}
}
}
}
&:hover {
// background-color: $fst;
ul li a {
// color: white;
font-weight: 600;
}
}
}
}
}
}
JS:
$(function(){
moveLogoToMiddle();
});
//将logo移动主菜单中间
function moveLogoToMiddle() {
const $menu = $(".header menu");
const $logo = $(".Logo");
const $menuItems = $menu.find("ul li.menutop.li3");
// 先移除 Logo(避免重复插入)
$logo.detach();
// 用 <li> 包裹 Logo
const $logoLi = $("<li class='logo'></li>").append($logo);
$logoLi.insertAfter($menuItems);
}
|