关于父元素的transform导致子元素的fixed定位错误
关于父元素的transform导致子元素的fixed定位错误
踩坑|2024-1-8|最后更新: 2024-1-8
type
status
date
slug
summary
tags
category
icon
password
Blocking
Blocked by
top
URL
Sub-item
Parent item

背景

做tab切换器时,做拖拽排序功能,如下图。使用react-beautiful-dnd,拖动时被拖动的tab会出现定位偏移。
notion image

排查

  1. 配置错误?
反复查看配置后,确认公司的 popovercard 组件和dnd确定无误。
  1. css样式冲突?
dnd是通过fixed定位,popovercard是通过fixed+transform。然后查资料发现父元素的transform会影响子元素的fixed定位。

临时解决方法

在子元素再增加相反的transform来暂时解决。
class (类)styled-componets props写法
Loading...