我需要最后一步进入View,但不能丢失标题,(因为scrollIntoView也垂直滚动)
如何实现它仅水平滚动而不垂直滚动到视图中
const App = () => {
React.useEffect(() => {
const activeStep = document.querySelector(".ant-steps-item-
current");
if (activeStep) {
activeStep.scrollIntoView({ behavior: "smooth", inline:
"center" });
}
}, []);
return (
<div style={{ minHeight: "200vh" }}>
<div style={{ height: "150px", fontSize:
"5rem"}}>Title</div>
<Steps>
{steps.map((s, step) => {
const status = s === "step9" ? "current" : "";
return (
<Steps.Step status={status} key={step} title={s}
description={s} />
);
})}
</Steps>
</div>
Run Code Online (Sandbox Code Playgroud)
);};
你可以看到一个代码沙箱