css - 如何修复 react-datepicker 总是移到下一行并将其他人推到下一行
问题描述
我有一个react
组件,我在其中input
使用react-datepicker
. 问题是,react-datepicker
元素总是移动到下一行,而不是所有字段都在同一行。虽然顶部div
被声明为flex
. 如果我删除react-datepicker
然后元素正确对齐。一旦datepicker
添加,表单就会失去样式。
<App />
component
:
return (
<div className="container">
<div className="app-wrapper">
<div>
<Form />
</div>
</div>
</div>
);
<Form />
component
如下所示:
return (
<form onSubmit={onFormSubmit}>
<input
type="text"
className="task-title"
/>
<input
type="text"
className="task-description"
/>
<DatePicker
className="datePicker"
selected={dueDate}
onChange={onDueDateChange}
name="Date"
dateFormat="yyyy-MM-dd"
/>
<button type="submit" className="button-add" />
</form>
);
CSS:
.container {
display: flex;
background: linear-gradient(to right bottom, #82cbe1, #66acc8);
width: 100%;
min-height: 100vh;
justify-content: center;
align-items: center;
}
.app-wrapper {
background-color: #94b2c4;
min-width: 0;
min-height: 0;
padding: 30px;
box-sizing: border-box;
border-radius: 10px;
box-shadow: 3px 6px 40px #000;
margin-bottom: 10px;
}
.task-description {
outline: none;
width: 450px;
padding: 15px;
margin-right: 5px;
font-size: 20px;
color: #ccc;
background-color: #000000;
border: 1px solid #66acc8;
border-radius: 10px;
}
.datePicker {
outline: none;
width: 140px;
padding: 15px;
margin-right: 5px;
font-size: 20px;
color: #ccc;
background-color: #000000;
border: 1px solid #66acc8;
border-radius: 10px;
}
.task-title,
.task-description,
.datePicker,
.button-add {
margin-bottom: 10px;
}
.button-add {
width: 60px;
padding: 15px 15px;
font-size: 20px;
border-radius: 10px;
border: 0;
background-color: #71def1;
cursor: pointer;
}
解决方案
推荐阅读
- matlab - 调整图形大小时,辅助轴会移位
- java - 哪些对象在 Java Card 中是持久的,什么时候持久?
- javascript - 如何使用javascript在与文本相同的行中添加按钮?
- java - 编写多线程的最佳方法
- sql - 如何查找输入值不合适的记录
- tensorflow - 张量流 sigmoid 函数不起作用
- pip - 无法 PIP 安装 Python ftfy 包
- php - 从 php curl 调用渲染 .NET 视图
- android - 如何在屏幕中心的所有小部件顶部显示 CircularProgressIndicator
- django - Django 无法访问 Azure 挂载的存储