sidebar.scss 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. /* $sideBarWidth: vertical 模式下主体内容距离网页文档左侧的距离 */
  2. @mixin merge-style($sideBarWidth) {
  3. @media screen and (width >= 150px) and (width <= 420px) {
  4. .app-main-nofixed-header {
  5. overflow-y: hidden;
  6. }
  7. }
  8. @media screen and (width >= 420px) {
  9. .app-main-nofixed-header {
  10. overflow: hidden;
  11. }
  12. }
  13. /* 修复 windows 下双滚动条问题 https://github.com/pure-admin/vue-pure-admin/pull/936#issuecomment-1968125992 */
  14. .el-popper.pure-scrollbar {
  15. overflow: hidden;
  16. }
  17. /* popper menu 超出内容区可滚动 */
  18. .pure-scrollbar {
  19. max-height: calc(100vh - calc(50px * 2.5));
  20. overflow: hidden auto;
  21. }
  22. .sub-menu-icon {
  23. margin-right: 5px;
  24. font-size: 18px;
  25. svg {
  26. width: 18px;
  27. height: 18px;
  28. }
  29. }
  30. .set-icon,
  31. .fullscreen-icon {
  32. display: flex;
  33. align-items: center;
  34. justify-content: center;
  35. width: 40px;
  36. height: 48px;
  37. cursor: pointer;
  38. }
  39. .main-container {
  40. position: relative;
  41. height: 100vh;
  42. min-height: 100%;
  43. margin-left: $sideBarWidth;
  44. background: #f0f2f5;
  45. /* main-content 属性动画 */
  46. transition: margin-left var(--pure-transition-duration);
  47. .el-scrollbar__wrap {
  48. height: 100%;
  49. overflow: auto;
  50. }
  51. }
  52. .fixed-header {
  53. position: fixed;
  54. top: 0;
  55. right: 0;
  56. z-index: 998;
  57. width: calc(100% - #{$sideBarWidth});
  58. /* fixed-header 属性左上角动画 */
  59. transition: width var(--pure-transition-duration);
  60. }
  61. .main-hidden {
  62. margin-left: 0 !important;
  63. .fixed-header {
  64. width: 100% !important;
  65. + .app-main {
  66. padding-top: 37px !important;
  67. }
  68. }
  69. }
  70. .sidebar-container {
  71. position: fixed;
  72. top: 0;
  73. bottom: 0;
  74. left: 0;
  75. z-index: 1001;
  76. width: $sideBarWidth !important;
  77. height: 100%;
  78. overflow: visible;
  79. font-size: 0;
  80. background: var(--pure-theme-menu-bg) !important;
  81. border-right: 1px solid var(--pure-border-color);
  82. /* 展开动画 */
  83. transition: width var(--pure-transition-duration);
  84. .scrollbar-wrapper {
  85. overflow-x: hidden !important;
  86. }
  87. .el-scrollbar__bar.is-vertical {
  88. right: 0;
  89. }
  90. &.has-logo {
  91. .el-scrollbar.pc {
  92. /* logo: 48px、leftCollapse: 40px、leftCollapse-shadow: 4px */
  93. height: calc(100% - 92px);
  94. }
  95. /* logo: 48px */
  96. .el-scrollbar.mobile {
  97. height: calc(100% - 48px);
  98. }
  99. }
  100. &.no-logo {
  101. .el-scrollbar.pc {
  102. /* leftCollapse: 40px、leftCollapse-shadow: 4px */
  103. height: calc(100% - 44px);
  104. }
  105. .el-scrollbar.mobile {
  106. height: 100%;
  107. }
  108. }
  109. .is-horizontal {
  110. display: none;
  111. }
  112. a {
  113. display: flex;
  114. flex-wrap: wrap;
  115. width: 100%;
  116. }
  117. .el-menu {
  118. height: 100%;
  119. background-color: transparent !important;
  120. border: none;
  121. }
  122. .el-menu-item,
  123. .el-sub-menu__title {
  124. height: 50px;
  125. color: var(--pure-theme-menu-text);
  126. background-color: transparent !important;
  127. &:hover {
  128. color: var(--pure-theme-menu-title-hover) !important;
  129. }
  130. div,
  131. span {
  132. height: 50px;
  133. line-height: 50px;
  134. }
  135. }
  136. .submenu-title-noDropdown,
  137. .el-sub-menu__title {
  138. &:hover {
  139. background-color: transparent;
  140. }
  141. }
  142. .is-active > .el-sub-menu__title,
  143. .is-active.submenu-title-noDropdown {
  144. color: var(--pure-theme-sub-menu-active-text) !important;
  145. i {
  146. color: var(--pure-theme-sub-menu-active-text) !important;
  147. }
  148. }
  149. .is-active {
  150. color: var(--pure-theme-sub-menu-active-text) !important;
  151. transition: color 0.3s;
  152. }
  153. .el-menu-item.is-active.nest-menu > * {
  154. z-index: 1;
  155. color: #fff;
  156. }
  157. .el-menu-item.is-active.nest-menu::before {
  158. position: absolute;
  159. inset: 0 8px;
  160. clear: both;
  161. margin: 4px 0;
  162. content: "";
  163. background: var(--el-color-primary) !important;
  164. border-radius: 3px;
  165. }
  166. .el-menu .el-menu--inline .el-sub-menu__title,
  167. & .el-sub-menu .el-menu-item {
  168. min-width: $sideBarWidth !important;
  169. font-size: 14px;
  170. background-color: var(--pure-theme-sub-menu-bg) !important;
  171. }
  172. /* 有子集的激活菜单左侧小竖条 */
  173. .el-menu--collapse
  174. .is-active.outer-most.el-sub-menu
  175. > .el-sub-menu__title::before {
  176. position: absolute;
  177. top: 0;
  178. left: 0;
  179. clear: both;
  180. width: 2px;
  181. height: 100%;
  182. content: "";
  183. background-color: var(--pure-theme-menu-active-before);
  184. transform: translateY(0);
  185. transition: all var(--pure-transition-duration) ease-in-out;
  186. }
  187. .el-menu--collapse .outer-most.el-sub-menu > .el-sub-menu__title::before {
  188. position: absolute;
  189. top: 50%;
  190. display: block;
  191. width: 3px;
  192. height: 0;
  193. content: "";
  194. transform: translateY(-50%);
  195. }
  196. /* 无子集的激活菜单背景 */
  197. .is-active.submenu-title-noDropdown.outer-most > * {
  198. z-index: 1;
  199. color: #fff;
  200. }
  201. .is-active.submenu-title-noDropdown.outer-most::before {
  202. position: absolute;
  203. inset: 0 8px;
  204. clear: both;
  205. margin: 4px 0;
  206. content: "";
  207. background: var(--el-color-primary) !important;
  208. border-radius: 3px;
  209. }
  210. }
  211. /* vertical 菜单折叠 */
  212. .el-menu--vertical {
  213. .el-menu--popup {
  214. background-color: var(--pure-theme-sub-menu-bg) !important;
  215. .el-menu-item {
  216. span {
  217. font-size: 14px;
  218. }
  219. }
  220. }
  221. & > .el-menu {
  222. i,
  223. svg {
  224. margin-right: 5px;
  225. }
  226. }
  227. .is-active > .el-sub-menu__title,
  228. .is-active.submenu-title-noDropdown {
  229. color: var(--pure-theme-sub-menu-active-text) !important;
  230. i {
  231. color: var(--pure-theme-sub-menu-active-text) !important;
  232. }
  233. }
  234. /* 子菜单中还有子菜单 */
  235. .el-menu .el-sub-menu__title {
  236. min-width: $sideBarWidth !important;
  237. font-size: 14px;
  238. background-color: var(--pure-theme-sub-menu-bg) !important;
  239. }
  240. .el-menu-item,
  241. .el-sub-menu__title {
  242. height: 50px;
  243. line-height: 50px;
  244. color: var(--pure-theme-menu-text);
  245. background-color: var(--pure-theme-sub-menu-bg);
  246. &:hover {
  247. color: var(--pure-theme-menu-title-hover) !important;
  248. }
  249. }
  250. .is-active {
  251. color: var(--pure-theme-sub-menu-active-text) !important;
  252. transition: color 0.3s;
  253. }
  254. .el-menu-item.is-active.nest-menu > * {
  255. z-index: 1;
  256. color: #fff;
  257. }
  258. .el-menu-item.is-active.nest-menu::before {
  259. position: absolute;
  260. inset: 0 8px;
  261. clear: both;
  262. content: "";
  263. background: var(--el-color-primary) !important;
  264. border-radius: 3px;
  265. }
  266. .el-menu-item,
  267. .el-sub-menu {
  268. .iconfont {
  269. font-size: 18px;
  270. }
  271. .el-menu-tooltip__trigger {
  272. width: 54px;
  273. padding: 0;
  274. }
  275. }
  276. }
  277. /* horizontal 菜单 */
  278. .el-menu--horizontal {
  279. & > .el-sub-menu .el-sub-menu__icon-arrow {
  280. position: static !important;
  281. margin-top: 0;
  282. }
  283. /* 无子菜单时激活 border-bottom */
  284. a > .is-active.submenu-title-noDropdown {
  285. border-bottom: 2px solid var(--el-menu-active-color);
  286. }
  287. .el-menu--popup {
  288. background-color: var(--pure-theme-sub-menu-bg) !important;
  289. a > .is-active.submenu-title-noDropdown {
  290. border-bottom: none;
  291. }
  292. .el-menu-item {
  293. color: var(--pure-theme-menu-text);
  294. background-color: var(--pure-theme-sub-menu-bg);
  295. span {
  296. font-size: 14px;
  297. }
  298. }
  299. .el-sub-menu__title {
  300. color: var(--pure-theme-menu-text);
  301. }
  302. }
  303. /* 子菜单中还有子菜单 */
  304. .el-menu .el-sub-menu__title {
  305. min-width: $sideBarWidth !important;
  306. font-size: 14px;
  307. background-color: var(--pure-theme-sub-menu-bg) !important;
  308. &:hover {
  309. color: var(--pure-theme-menu-title-hover) !important;
  310. }
  311. }
  312. .is-active > .el-sub-menu__title,
  313. .is-active.submenu-title-noDropdown {
  314. color: var(--pure-theme-sub-menu-active-text) !important;
  315. i {
  316. color: var(--pure-theme-sub-menu-active-text) !important;
  317. }
  318. }
  319. .nest-menu .el-sub-menu > .el-sub-menu__title,
  320. .el-menu-item {
  321. &:hover {
  322. color: var(--pure-theme-menu-title-hover) !important;
  323. }
  324. }
  325. .el-menu-item.is-active {
  326. color: var(--pure-theme-sub-menu-active-text) !important;
  327. transition: color 0.3s;
  328. }
  329. .el-menu-item.is-active.nest-menu > * {
  330. z-index: 1;
  331. color: #fff;
  332. }
  333. .el-menu-item.is-active.nest-menu::before {
  334. position: absolute;
  335. inset: 0 5px;
  336. clear: both;
  337. content: "";
  338. background: var(--el-color-primary) !important;
  339. border-radius: 3px;
  340. }
  341. }
  342. .horizontal-header {
  343. display: flex;
  344. align-items: center;
  345. justify-content: space-around;
  346. width: 100%;
  347. height: 48px;
  348. background: var(--pure-theme-menu-bg) !important;
  349. .horizontal-header-left {
  350. display: flex;
  351. align-items: center;
  352. width: auto;
  353. min-width: 200px;
  354. height: 100%;
  355. padding-left: 10px;
  356. cursor: pointer;
  357. transition: all var(--pure-transition-duration) ease;
  358. img {
  359. display: inline-block;
  360. height: 32px;
  361. }
  362. span {
  363. display: inline-block;
  364. height: 32px;
  365. margin: 2px 0 0 12px;
  366. overflow: hidden;
  367. text-overflow: ellipsis;
  368. font-size: 18px;
  369. font-weight: 600;
  370. line-height: 32px;
  371. color: var(--pure-theme-sub-menu-active-text);
  372. white-space: nowrap;
  373. }
  374. }
  375. .horizontal-header-menu {
  376. flex: 1;
  377. align-items: center;
  378. min-width: 0;
  379. height: 100%;
  380. }
  381. .horizontal-header-right {
  382. display: flex;
  383. align-items: center;
  384. justify-content: flex-end;
  385. min-width: 340px;
  386. color: var(--pure-theme-sub-menu-active-text);
  387. /* 搜索 */
  388. .search-container,
  389. /* 国际化 */
  390. .globalization,
  391. /* 全屏 */
  392. .fullscreen-icon,
  393. /* 消息通知 */
  394. .dropdown-badge,
  395. /* 用户名 */
  396. .el-dropdown-link,
  397. /* 设置 */
  398. .set-icon {
  399. &:hover {
  400. background: var(--pure-theme-menu-hover);
  401. }
  402. }
  403. .dropdown-badge {
  404. height: 48px;
  405. color: var(--pure-theme-sub-menu-active-text);
  406. }
  407. .globalization {
  408. width: 40px;
  409. height: 48px;
  410. padding: 11px;
  411. color: var(--pure-theme-sub-menu-active-text);
  412. cursor: pointer;
  413. outline: none;
  414. }
  415. .el-dropdown-link {
  416. display: flex;
  417. align-items: center;
  418. justify-content: space-around;
  419. height: 48px;
  420. padding: 10px;
  421. color: var(--pure-theme-sub-menu-active-text);
  422. cursor: pointer;
  423. p {
  424. font-size: 14px;
  425. }
  426. img {
  427. width: 22px;
  428. height: 22px;
  429. border-radius: 50%;
  430. }
  431. }
  432. }
  433. .el-menu {
  434. width: 100% !important;
  435. height: 100%;
  436. background-color: transparent;
  437. border: none;
  438. }
  439. .el-menu-item,
  440. .el-sub-menu__title {
  441. padding-right: var(--el-menu-base-level-padding);
  442. color: var(--pure-theme-menu-text);
  443. &:hover {
  444. color: var(--pure-theme-menu-title-hover) !important;
  445. }
  446. }
  447. .submenu-title-noDropdown,
  448. .el-sub-menu__title {
  449. height: 48px;
  450. line-height: 48px;
  451. background: var(--pure-theme-menu-bg) !important;
  452. svg {
  453. position: static !important;
  454. }
  455. }
  456. .is-active > .el-sub-menu__title,
  457. .is-active.submenu-title-noDropdown {
  458. color: var(--pure-theme-sub-menu-active-text) !important;
  459. i {
  460. color: var(--pure-theme-sub-menu-active-text) !important;
  461. }
  462. }
  463. .is-active {
  464. color: var(--pure-theme-sub-menu-active-text) !important;
  465. transition: color 0.3s;
  466. }
  467. }
  468. .el-menu--collapse .el-menu .el-sub-menu {
  469. min-width: $sideBarWidth !important;
  470. }
  471. /* 手机端 */
  472. .mobile {
  473. .fixed-header {
  474. width: 100% !important;
  475. transition: width var(--pure-transition-duration);
  476. }
  477. .main-container {
  478. margin-left: 0 !important;
  479. }
  480. .sidebar-container {
  481. z-index: 2001;
  482. width: $sideBarWidth;
  483. transition: transform var(--pure-transition-duration);
  484. }
  485. &.hideSidebar {
  486. .sidebar-container {
  487. pointer-events: none;
  488. transform: translate3d(-$sideBarWidth, 0, 0);
  489. transition-duration: 0.3s;
  490. }
  491. }
  492. }
  493. }
  494. body[layout="vertical"] {
  495. $sideBarWidth: 210px;
  496. @include merge-style($sideBarWidth);
  497. .el-menu--collapse {
  498. width: 54px;
  499. }
  500. .sidebar-logo-container {
  501. background: var(--pure-theme-sidebar-logo);
  502. }
  503. .hideSidebar {
  504. .fixed-header {
  505. width: calc(100% - 54px);
  506. transition: width var(--pure-transition-duration);
  507. }
  508. .sidebar-container {
  509. width: 54px !important;
  510. transition: width var(--pure-transition-duration);
  511. .is-active.submenu-title-noDropdown.outer-most {
  512. background: transparent !important;
  513. }
  514. }
  515. .main-container {
  516. margin-left: 54px;
  517. }
  518. /* 菜单折叠 */
  519. .el-menu--collapse {
  520. .el-sub-menu {
  521. & > .el-sub-menu__title {
  522. & > span {
  523. visibility: visible;
  524. width: 100%;
  525. height: 100%;
  526. text-align: center;
  527. }
  528. }
  529. }
  530. .submenu-title-noDropdown {
  531. background: transparent !important;
  532. }
  533. .el-sub-menu__title {
  534. padding: 0;
  535. }
  536. }
  537. .sub-menu-icon {
  538. margin-right: 0;
  539. }
  540. }
  541. /* 搜索 */
  542. .search-container,
  543. /* 国际化 */
  544. .globalization,
  545. /* 全屏 */
  546. .fullscreen-icon,
  547. /* 消息通知 */
  548. .dropdown-badge,
  549. /* 用户名 */
  550. .el-dropdown-link,
  551. /* 设置 */
  552. .set-icon {
  553. &:hover {
  554. background: #f6f6f6;
  555. }
  556. }
  557. }
  558. body[layout="horizontal"] {
  559. $sideBarWidth: 0;
  560. @include merge-style($sideBarWidth);
  561. .el-menu {
  562. --el-menu-hover-text-color: var(--pure-theme-menu-text) !important;
  563. }
  564. .fixed-header,
  565. .main-container {
  566. transition: none !important;
  567. }
  568. .fixed-header {
  569. width: 100%;
  570. }
  571. }
  572. body[layout="mix"] {
  573. $sideBarWidth: 210px;
  574. @include merge-style($sideBarWidth);
  575. .el-menu--collapse {
  576. width: 54px;
  577. }
  578. .el-menu {
  579. --el-menu-hover-bg-color: transparent !important;
  580. --el-menu-hover-text-color: var(--pure-theme-menu-text) !important;
  581. }
  582. .hideSidebar {
  583. .fixed-header {
  584. width: calc(100% - 54px);
  585. transition: width var(--pure-transition-duration);
  586. }
  587. .sidebar-container {
  588. width: 54px !important;
  589. transition: width var(--pure-transition-duration);
  590. .is-active.submenu-title-noDropdown.outer-most {
  591. background: transparent !important;
  592. }
  593. }
  594. .main-container {
  595. margin-left: 54px;
  596. }
  597. /* 菜单折叠 */
  598. .el-menu--collapse {
  599. .el-sub-menu {
  600. & > .el-sub-menu__title {
  601. padding: 0;
  602. & > span {
  603. visibility: visible;
  604. width: 100%;
  605. height: 100%;
  606. text-align: center;
  607. }
  608. }
  609. }
  610. }
  611. }
  612. }