[英]How can I change the width of my datepicker?
I am trying to change the width of the datepiker but I do not achieve.我正在尝试更改 datepiker 的宽度,但没有实现。
Here is my code:这是我的代码:
import React from "react";
import ReactDOM from "react-dom";
import { DatePicker, RangeDatePicker } from "@y0c/react-datepicker";
// import calendar style
// You can customize style by copying asset folder.
import "@y0c/react-datepicker/assets/styles/calendar.scss";
// Please include the locale you want to use.
// and delivery props to calendar component
import "dayjs/locale/ko";
import "dayjs/locale/en";
import "./styles.css";
const Panel = ({ header, children }) => (
<div style={{ height: "300px" }}>
<h1>{header}</h1>
<div>{children}</div>
</div>
);
function App() {
const onChange = title => (...args) => console.log(title, args);
return (
<div className="App">
<Panel header="Simple DatePicker">
<DatePicker style={{width: "800px"}} showToday onChange={onChange("DatePicker")} />
</Panel>
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
I tried this style={{width: "800px"}}
but it does not work... Could you help me please?我试过这个
style={{width: "800px"}}
但它不起作用......你能帮帮我吗?
Thank you very much !非常感谢 !
NB: my code is here https://codesandbox.io/s/react-datepicker-forked-ljh6y注意:我的代码在这里https://codesandbox.io/s/react-datepicker-forked-ljh6y
You can directly modify the style of the generated element:可以直接修改生成元素的样式:
.picker-input__text {
width: 800px;
}
I assume that you would also like it be resized for smaller screens.我假设您还希望它针对较小的屏幕调整大小。 You can also include
您还可以包括
@media (max-width: 900px) {
.picker-input__text {
width: 250px;
}
}
Forked Codesandbox: https://codesandbox.io/s/react-datepicker-forked-pn9fr分叉的 Codesandbox: https://codesandbox.io/s/react-datepicker-forked-pn9fr
You might wanna use你可能想用
.picker-input__text { width: 800px; }
OR you can use Standalone Calendar component and add adjoining logic with your custom input.或者,您可以使用独立日历组件并使用自定义输入添加相邻逻辑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.