[英]Prevent date picker from scrolling with page
我正在制作一個由antd組成的日期選擇器的反應應用程序
簡單的 index.js代碼:
import React from "react";
import ReactDOM from "react-dom";
import { DatePicker } from "antd";
import "antd/dist/antd.css";
import "./index.css";
ReactDOM.render(
<div className="App">
<h1>Select date-picker scroll bug.</h1>
<div
style={{ marginTop: "16px", width: 500, overflow: "scroll", height: 400 }}
>
<DatePicker />
<div style={{ minHeight: 500 }}></div>
</div>
</div>,
document.getElementById("root")
);
工作示例:
重現:如果用戶點擊輸入,日期選擇器會顯示,但是當我們嘗試向下滾動時,日期選擇器也會隨着頁面滾動。
預期結果:日期選擇器不應滾動,它需要位於輸入框下方。
任何幫助都將是非常可觀的。 提前致謝。
這在他們的常見問題解答中有所描述: https://ant.design/docs/react/faq#How-do-I-prevent-Select-Dropdown-DatePicker-TimePicker-Popover-Popconfirm-scrolling-with-the-page ?
position: "relative"
添加到父元素。getPopupContainer={trigger => trigger.parentElement}
添加到您的DatePicker
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.