如何将自定义样式添加到React DatePicker(Hackerone)?
我想让此DateTime Picker占用整个屏幕,并更改某些部分的样式,例如每个时间插槽和一天的大小。
我从 https://reactdatepicker.com/#example-default.com/#example-default 回购是 https://github.com/hacker.com/hacker0x01/reaect-datepicker
任何帮助值得赞赏!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以检查示例自定义日历类名称。
它使用
datePicker
propertycalendarclassname =“ rasta-stripes”
定义了自定义类名称。 class-namerasta-stripes
定义如下:因此,如您所见,要样式的某些零件,只需引用类对datepicker for自身覆盖它的用途即可。您可以通过浏览您的首选项检查来源检查哪些类存在。
为了使其全屏幕,例如,只需覆盖
react-datepicker-popper
class-name通过删除transform
并添加left:0;右:0;顶部:0;底部:0;
,然后根据您的需求更改每个固定尺寸的孩子。You can check in the examples the Custom calendar class name.
It defines a custom class name with the
DatePicker
propertycalendarClassName="rasta-stripes"
. The class-namerasta-stripes
is defined as follow:So, as you can see, to style some parts just make a reference to the classes React DatePicker uses for itself to override it. You can check which classes exist by inspecting the sources with the browser of your preference.
To make it full screen for example just override the
react-datepicker-popper
class-name by removingtransform
and addingleft: 0; right: 0; top: 0; bottom: 0;
and then change every fixed size child to your needs.最直接的方法是覆盖内置的。
react> react-datepicker__day
)很难覆盖。为此,您需要在值之后包含
!重要
修改器:如果您不想直接覆盖这些内置类,也可以定义自定义类名称并将其添加到您的全局CSS文件像以前一样:
The most direct way is to override the built-in react-datepicker css classes.
react-datepicker__day
)Some properties are harder to override. For these, you need to include the
!important
modifier after the value:If you don't want to directly override these built-in classes, you can also define custom class names and add them to your global css file like before: