|
|
CSS代码,仿Chrome标签页(梯形标签页),用于文件管理软件Tablacus Explorer。
想做一个改进,就是提升文字位置,如图:
CSS代码(待修改)
- /* ============================================
- 基础设置与颜色定义
- ============================================= */
- /* 1. 去除默认的边框、阴影和凸起效果 */
- .tab, .tab2, .tab3, .activetab,
- .tab:hover, .tab2:hover, .tab3:hover {
- box-shadow: none !important;
- border: none !important;
- outline: none !important;
- }
- /* 2. 标签栏整体背景 */
- .tab0 {
- /* 这里设置标签栏底色,建议使用深蓝灰色 */
- background-color: #648ca5;
- padding: 5px 0 0 10px; /* 顶部留点空隙,左侧留空隙 */
- height: 30px; /* 强制高度,防止布局乱跳 */
- }
- /* =============================================
- 标签通用形状 (所有标签都生效的样式)
- ============================================ */
- .tab, .tab2, .tab3, .activetab {
- position: relative;
- display: inline-block;
- height: 26px; /* 标签高度 */
- line-height: 28px; /* 文字垂直居中微调 */
- padding: 0px 10px; /* 文字左右间距 */
- margin: 0 8px; /* 标签之间的重叠/间距,负数可以让它们重叠 */
- font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
- cursor: default;
- vertical-align: top; /* 顶部对齐 */
- }
- /* 通用的伪元素设置 (用于显示梯形两侧) */
- .tab:before, .tab:after,
- .tab2:before, .tab2:after,
- .tab3:before, .tab3:after,
- .activetab:before, .activetab:after {
- content: "";
- position: absolute;
- bottom: 0;
- width: 25px; /* SVG图片的宽度 */
- height: 26px; /* 必须与标签高度一致 */
- pointer-events: none; /* 防止鼠标点到圆角上没反应 */
- }
- /* 左侧圆角位置 */
- .tab:before, .tab2:before, .tab3:before, .activetab:before {
- left: -21px; /* 根据SVG宽度调整,负值 */
- }
- /* 右侧圆角位置 (镜像翻转) */
- .tab:after, .tab2:after, .tab3:after, .activetab:after {
- right: -21px;
- transform: scaleX(-1);
- }
- /* =============================================
- 状态 A: 非当前页 (普通标签)
- ============================================= */
- .tab, .tab2, .tab3 {
- /* 非当前页背景色 (稍浅于底色,或灰色) */
- background-color: #8daabb;
- color: #FFFFFF; /* 非当前页文字颜色 */
- z-index: 1; /* 层级低,被当前页压住 */
- }
- /* 非当前页的梯形 SVG (填充色必须对应上面的 background-color: #8daabb) */
- .tab:before, .tab:after,
- .tab2:before, .tab2:after,
- .tab3:before, .tab3:after {
- /* 下方 fill=%238daabb 就是颜色代码,如果改背景色,这里也要改 */
- background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%238daabb%22%20d%3D%22M24%200C9%200%2015%2026%200%2026h25V0h-1z%22%2F%3E%3C%2Fsvg%3E");
- }
- /* ==============================================
- 状态 B: 鼠标悬停 (Hover)
- ============================================= */
- .tab:hover, .tab2:hover, .tab3:hover {
- /* 悬停时的背景色 (浅蓝色) */
- background-color: #bfe0f0;
- color: #000;
- z-index: 5; /* 悬停时层级提高 */
- }
- /* 悬停时的梯形 SVG (填充色 fill=%23bfe0f0) */
- .tab:hover:before, .tab:hover:after,
- .tab2:hover:before, .tab2:hover:after,
- .tab3:hover:before, .tab3:hover:after {
- background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%23bfe0f0%22%20d%3D%22M24%200C9%200%2015%2026%200%2026h25V0h-1z%22%2F%3E%3C%2Fsvg%3E");
- }
- /* =============================================
- 状态 C: 当前页 (Active)
- ============================================= */
- .activetab {
- /* 当前页背景色 (白色) */
- background-color: #ffffff;
- color: #000; /* 当前页文字颜色 */
- z-index: 10; /* 层级最高,压在所有标签上面 */
- font-weight: normal;
- }
- /* 当前页的梯形 SVG (填充色 fill=%23ffffff) */
- .activetab:before, .activetab:after {
- background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%23ffffff%22%20d%3D%22M24%200C9%200%2015%2026%200%2026h25V0h-1z%22%2F%3E%3C%2Fsvg%3E");
- }
复制代码
|
|