diff --git a/src/components/common/TabCommon/TabCommon.module.scss b/src/components/common/TabCommon/TabCommon.module.scss index e087018be..6dcb203c1 100644 --- a/src/components/common/TabCommon/TabCommon.module.scss +++ b/src/components/common/TabCommon/TabCommon.module.scss @@ -2,27 +2,26 @@ .tabWapper{ @apply flex flex-col w-full; .tabHeader{ - @apply relative; + @apply flex; .tabList { @apply flex; position: relative; border-bottom: 2px solid #FBFBFB; padding: 0.8rem 0; - width: 100%; &.center{ - @apply justify-center; + margin: auto; } - } - .slider { - @apply inline-block; - height: .2rem; - border-radius: 3px; - background-color: var(--primary); - position: absolute; - z-index: 1200; - bottom: 0; - transition: all .25s linear; + .slider { + @apply inline-block; + height: .2rem; + border-radius: 3px; + background-color: var(--primary); + position: absolute; + z-index: 1200; + bottom: 0; + transition: all .25s linear; + } } } } diff --git a/src/components/common/TabCommon/TabCommon.tsx b/src/components/common/TabCommon/TabCommon.tsx index ea0a762b3..afefb0da3 100644 --- a/src/components/common/TabCommon/TabCommon.tsx +++ b/src/components/common/TabCommon/TabCommon.tsx @@ -40,10 +40,11 @@ const TabCommon = ({ const active = headerRef.current?.children .item(index) ?.getBoundingClientRect() + const header = headerRef.current?.getBoundingClientRect() const current = slider.current - if (current && active) { + if (current && active && header) { let width = active.width - 24 <= 0 ? 24 : active.width - 24 - let left = active.left + let left = active.left - header.left current.style.width = width.toString() + 'px' current.style.left = left.toString() + 'px' } @@ -69,8 +70,8 @@ const TabCommon = ({ ) })} -
+
{Children.map(children, (tab, index) => {