diff --git a/components/_util/isFlexSupported.tsx b/components/_util/isFlexSupported.tsx new file mode 100644 index 0000000000..78b9babed7 --- /dev/null +++ b/components/_util/isFlexSupported.tsx @@ -0,0 +1,10 @@ +export default function isFlexSupported() { + if (typeof window !== 'undefined' && window.document && window.document.documentElement) { + const { documentElement } = window.document; + return 'flex' in documentElement.style || + 'webkitFlex' in documentElement.style || + 'Flex' in documentElement.style || + 'msFlex' in documentElement.style; + } + return false; +} diff --git a/components/tabs/index.tsx b/components/tabs/index.tsx index dc0dcde7fc..5cde7c8dab 100755 --- a/components/tabs/index.tsx +++ b/components/tabs/index.tsx @@ -1,11 +1,13 @@ import React from 'react'; import { cloneElement } from 'react'; +import { findDOMNode } from 'react-dom'; import RcTabs, { TabPane } from 'rc-tabs'; import ScrollableInkTabBar from 'rc-tabs/lib/ScrollableInkTabBar'; import TabContent from 'rc-tabs/lib/TabContent'; import classNames from 'classnames'; import Icon from '../icon'; import warning from '../_util/warning'; +import isFlexSupported from '../_util/isFlexSupported'; export type TabsType = 'line' | 'card' | 'editable-card' export type TabsPosition = 'top' | 'right' | 'bottom' | 'left'; @@ -69,6 +71,14 @@ export default class Tabs extends React.Component { } } + componentDidMount() { + const NO_FLEX = ' no-flex'; + const tabNode = findDOMNode(this); + if (tabNode && !isFlexSupported() && tabNode.className.indexOf(NO_FLEX) === -1) { + tabNode.className += NO_FLEX; + } + } + render() { let { prefixCls, diff --git a/components/tabs/style/index.less b/components/tabs/style/index.less index 5c3e1bc277..d12d158b0a 100644 --- a/components/tabs/style/index.less +++ b/components/tabs/style/index.less @@ -313,10 +313,10 @@ .@{tab-prefix-cls}-no-animation, .@{tab-prefix-cls}-vertical { > .@{tab-prefix-cls}-content { - > &-animated { - transform: none!important; + &-animated { + transform: none !important; + margin-left: 0 !important; } - > .@{tab-prefix-cls}-tabpane-inactive { display: none; }