如何更改 ant-design Tabs 默认边框颜色

时间:2021-04-04 04:42:33

标签: javascript css reactjs antd ant-design-pro

我无法更改 antd Tabs 的默认边框颜色。

带有默认边框的标签: tabs-default-color

我想要的是: tabs-black-border

不知何故,我能够实现这一点,但它没有响应,需要更多时间。 它搞砸了手机屏幕等。

...
/* rest of css in codesandbox, https://codesandbox.io/s/so-change-antd-tabs-default-border-color-40gmb?file=/index.css */
...

  .ant-tabs-content-holder {
    border-width: 1px;
    border-color: grey;
    border-style: solid;
    padding: 1rem;
    background: white;
    position: relative;
  }

 .ant-tabs-content-holder:after {
    padding: 0;
    margin: 0;
    display: block;
    content: '';
    height: 1.1px;
    position: absolute;
    top: -1px;

    left:  0%;
    width: 24.8%;
    background-color: white;
  }

这就是它在移动屏幕上的样子。我想我可以为不同的屏幕宽度使用许多断点并更改 leftwidth.ant-tabs-content-holder:after 的百分比,但很乏味。

not-responsive-small-screen

如何以更简单的方式实现这一目标?任何的想法?我可以在 webpack 或 vars 中使用标签边框的任何蚂蚁设计 less 吗? antd docs 有风格道具吗?我将感谢您的帮助。

签出代码:codesandbox

2 个答案:

答案 0 :(得分:3)

.ant-tabs-card > .ant-tabs-nav .ant-tabs-tab { /* For tabs border */
  border-color: black;
}

.ant-tabs-top > .ant-tabs-nav::before { /* For the line to the right and close to the tabs */
  border-color: black;
}

.ant-tabs > .ant-tabs-nav { /* So that there is no gap between the content and tabs */
  margin-bottom: 0;
}

.ant-tabs-content-holder {
  padding: 15px;
  border: 1px solid black; /* Border for the content part */
  border-top: transparent; /* Remove the top border so that there is no overlap*/
}

你只需要覆盖上面的4个类来实现你的布局:

CodeSandbox Demo

输出:

enter image description here

答案 1 :(得分:2)

刚刚尝试覆盖现有边界(使用相同的选择器)似乎可以做到这一点。

https://codesandbox.io/s/so-change-antd-tabs-default-border-color-forked-tkg3h?file=/index.css