react-tabs 中的自定义样式似乎不起作用。底部边框消失,一旦选择了选项卡

Custom styling in react-tabs seems not working . Bottom border dissaperas as soons as the tab selected

提问人:NIKO VITZ 提问时间:3/1/2023 最后编辑:NIKO VITZ 更新时间:3/2/2023 访问量:463

问:

我正在为我的项目使用 react-tabs (https://github.com/reactjs/react-tabs)。我想在此基础上添加自定义样式。但是样式似乎无法正常工作

预期内容:预期输出 - 没有问题

我得到的问题是什么

一旦选项卡更改,底部边框就会消失。我想这是因为

.react-tabs__tab:focus { outline: none; }

我怎样才能解决这个问题?这是我现在的 SCSS `

.react-tabs__tab {
    font-family: 'Spoqa Han Sans Neo';
    font-style: normal;
    font-weight: 700;
    font-size: 18px;
    line-height: 24px;
    color: #999999;
}

.react-tabs__tab--selected{
    background: #fff;
    color: black;
    border: 1px solid transparent;
    border-radius: 5px 5px 0 0;
    padding-bottom: 18px;
    border-bottom: 3px solid #075453;
    font-family: 'Spoqa Han Sans Neo';
    font-style: normal;
    font-weight: 700;
    font-size: 18px;
    line-height: 24px;
    color: #333333;
}`

我的 jsx

import React from 'react';
import { Tabs, TabList, Tab, TabPanel } from 'react-tabs';
import 'react-tabs/style/react-tabs.css';
import './membersTabularView.scss';
const MembersTabularView = () => {
    return ( 
            <Tabs  >
                <TabList> 
                    <Tab>1</Tab>
                    <Tab>2</Tab>
                    <Tab>3</Tab>
                </TabList>

                <TabPanel>
                    <h2>Any content 1</h2>
                </TabPanel>
                <TabPanel>
                    <h2>Any content 2</h2>
                </TabPanel>
                <TabPanel>
                    <h2>Any content 3</h2>
                </TabPanel>
            </Tabs> 
    );
};

export default MembersTabularView;

沙盒链接 https://codesandbox.io/s/lucid-northcutt-3f617h?file=/src/App.js

css reactjs 前端 jsx react-tabs

评论

0赞 Praveen 3/1/2023
您需要为查询提供最低限度的可重现工作代码示例,以获得一些帮助。
0赞 Praveen 3/1/2023
尝试使用类似 codesandbox.io/s/react-new 的内容重现您的查询
0赞 NIKO VITZ 3/1/2023
codesandbox.io/s/lucid-northcutt-3f617h?file=/src/App.js

答:

2赞 C Ekanayake 3/2/2023 #1

如果删除 react-tabs__tab--selected 类中的背景颜色并覆盖 react-tabs_tab:focus: after content 属性,它应该可以按预期工作。最终的 SCSS 类如下所示。

.react-tabs__tab--selected {
      color: black;
      border: 1px solid transparent;
      border-radius: 5px 5px 0 0;
      padding-bottom: 18px;
      border-bottom: 3px solid #075453;
      font-family: "Spoqa Han Sans Neo";
      font-style: normal;
      font-weight: 700;
      font-size: 18px;
      line-height: 24px;
      color: #333333;
    }

 .react-tabs__tab:focus:after{
  content:none
  }

intended results replicated