柒比贰(7B2)
柒比贰(7B2)

暂无菜单项

首页/文章/教程文章/
访问MD

B2 Pro 主题【社交类型菜单】优化教程

娃哈哈喝牛奶
发布于 2021/5/28更新于 2021/5/28
6,459

本教程主要小优化了一下【社交类型菜单】样式,把这个菜单改成一层。之前我的子主题就用的这样的样式,但是有些小细节不好,本教程是升级版本☺️

本教程非常简单,先看一下修改效果:

我不推荐春哥把【社交类型菜单】改成这个样式,主要是这个样式可能是个小众喜欢的样式。如果喜欢这个样式大家可以自行修改。

下面是教程:

1、设置顶部菜单样式

设置项在:B2主题设置 – 模块管理 – 顶部 – 顶部布局样式,选择以下样式:

如果你选择的是其他样式的菜单,请不要添加下面的css代码,避免引起布局样式错乱!

2、添加css样式

请将以下css代码复制到你自己的css中。

以下修改推荐在子主题中修改!

/*优化头部header*/
.site-header.social-top{
    height: 58px;
    background: #FFFFFF;
}
.logo img{
    /*height: 22px;*/
}
.header-banner-left .menu li.current-menu-item a{
    color: #121212;
    font-weight: 600;
}
.site .site-header-in{
    box-shadow: none;
}
.site .site-header-in > div:last-child{
    box-shadow: 0px 2px 4px rgb(114 114 117 / 6%);
}
.social-top .header{
    height: 58px;
    border: none;
    background: #fff;
}
.social-top .site.up .header{
    background: #fff;
    z-index: 7;
}
.top-style-blur{
    display: none;
}
.social-top .header-banner{
    position: absolute;
}
.social-top .header-banner{
    transform: translate(0,0);
    transition: transform .3s;
}
.social-top .site.up .site-header-in .header-banner{
    transform: translate(0,-58px);
    transition: transform .3s,background-color .3s ease-out;
}
.social-top .header .wrapper{
    height: 58px;
    opacity: 0;
    transform: translate(0,20px);
    transition: transform .3s,background-color .3s ease-out,opacity .3s;
    -webkit-transition: transform .3s,background-color .3s ease-out,opacity .3s; /* Safari */
}
.social-top .site.up .site-header-in{
    transform: none;
    transition: none;
}
.social-top .site.up .top-style-bottom .wrapper{
    opacity: 1;
    transform: translate(0,0);
    transition: transform .3s,background-color .3s ease-out,opacity .3s;
    -webkit-transition: transform .3s,background-color .3s ease-out,opacity .3s; /* Safari */
}
.social-top .header-banner-left .menu li a{
    font-size: 15px;
}
.social-top .top-menu ul li.depth-0 > a{
    font-size: 15px;
    color: #8590A6; /*第二层导航菜单字体颜色修改,可以修改成自己颜色*/
    opacity: 1;
    height: 58px;
}
.social-top .top-menu ul li.depth-0 > a i{
    font-weight: 600;
}
.social-top .mobile-box{
    justify-content: normal;
}
.social-top .mobile-box .mobile-show{
    display: block;
}
.social-top .mobile-box .top-submit {
    position: absolute;
    right: 0;
    display: flex;
}

    /*移动样式优化*/
    @media screen and (max-width: 768px){
        .social-top .logo img{
            /*height: 20px;*/
        }
        .site-header.social-top{
            height: 90px;
        }
        .social-top .site.up .site-header-in{
            transform: translate(0,-43px);
            transition: transform .3s,background-color .3s ease-out;
        }
        .social-top .header .wrapper{
            opacity: 1;
            transform: none;
        }
        .social-top .site.up .site-header-in .header-banner{
            transform: none;
        }
        .social-top .top-submit {
            display: none !important;
        }
    }

我写的css代码不怎么规范?,大家可以根据自己网站风格自行修改~

添加完成后,就实现演示效果了~

至此教程结束,感谢阅读。如果对本教程有疑问或建议请在下面留言~

0 点赞
0 收藏
分享
29 讨论
反馈
教程文章
订阅0
取消订阅
29 讨论
热门最新
总结
评论区多数用户感谢分享并尝试了教程,部分用户询问CSS添加位置及如何去掉“写文章”按钮;有用户反馈移动端菜单展开bug,还有用户询问如何成为小乌鸦及子主题问题。
A19221

我也是小众?

3/9
优雅的雀斑

感谢分享?

1/16
hsd0321

请问在哪里添加CSS?

7/16
hsd0321

请问在哪里添加?

7/16
小飞鱼

.site-header.social-top { height: 58px; background-color: #ffffff; } .logo img { /*height: 22px;*/ } .header-banner-left .menu li.current-menu-item a { color: #121212; font-weight: 600; } .site .site-header-in { box-shadow: none; } .site .site-header-in > div:last-child { box-shadow: 0 2px 4px rgba(114, 114, 117, 0.06); } .social-top .header { height: 58px; border: none; background-color: #ffffff; } .social-top .site.up .header { background-color: #ffffff; z-index: 7; } .top-style-blur { display: none; } .social-top .header-banner { position: absolute; transform: translate(0, 0); transition: transform 0.3s; } .social-top .site.up .site-header-in .header-banner { transform: translate(0, -58px); transition: transform 0.3s, background-color 0.3s ease-out; } .social-top .header .wrapper { height: 58px; opacity: 0; transform: translate(0, 20px); transition: transform 0.3s, background-color 0.3s ease-out, opacity 0.3s; } .social-top .site.up .site-header-in { transform: none; transition: none; } .social-top .site.up .top-style-bottom .wrapper { opacity: 1; transform: translate(0, 0); transition: transform 0.3s, background-color 0.3s ease-out, opacity 0.3s; } .social-top .header-banner-left .menu li a { font-size: 15px; } .social-top .top-menu ul li.depth-0 > a { font-size: 15px; color: #8590a6; opacity: 1; height: 58px; font-weight: 600; } .social-top .top-menu ul li.depth-0 > a i { font-weight: 600; } .social-top .mobile-box { justify-content: normal; } .social-top .mobile-box .mobile-show { display: block; } .social-top .mobile-box .top-submit { position: absolute; right: 0; display: flex; } @media screen and (max-width: 768px) { .social-top .logo img { /*height: 20px;*/ } .site-header.social-top { height: 90px; } .social-top .site.up .site-header-in { transform: translate(0, -43px); transition: transform 0.3s, background-color 0.3s ease-out; } .social-top .header .wrapper { opacity: 1; transform: none; } .social-top .site.up .site-header-in .header-banner { transform: none; } .social-top .top-submit { bottom: 16px; } }

3/25
小飞鱼

感谢分享,很不错,很喜欢,但是使用以后右上角会有一个写文章的按钮,请问能否去掉。

3/24
susuifa

请问大佬用的是什么子主题?我自己添加了您的代码,没办法像您一样显示?

10/11
陈桥驿

6/8
速速网络

不错不错!!!

12/13
AndyZGS

11/29
0 / 600
细中粗
首页文档联系
柒比贰(7B2)
柒比贰(7B2)
首页购物导航播客视频文档下载
瓜奇中你最需要的是什么功能?
323 人投票单选
7月后结束
登录
连续打卡 0 天
2026年6月
我的通知
本周热帖
  • AI搜按钮有问题

    1
    6/3
  • 筛选标签展示有问题

    1
    6/3
  • 域名授权换绑能不能学习一下 子比主题

    2
    6/1
  • 前端提示这个是什么啊怎么解决 验证码的图片也无法正常显示

    2
    5/31
  • 发帖子是不是有问题啊,为期…

    1
    5/30
最新上架

Condor EDC Pouch 工具收纳包

春日力推

¥100-¥123
¥100-¥123

多规格演示:5.11 Tactical Rush 12 背包

满减

¥440-¥480
¥459-¥499

Olight i3T EOS 迷你手电筒

包邮

2600-5000
3000-5000

Nitecore NTK05 钛合金迷你钥匙刀

30天无理由退换

¥399
¥399
所有的成功,都源自一个勇敢的开始
不辜负每一个勇敢的开始
关于帮助文档FAQ协议
柒比贰(7B2) © 2026