css - 定位输入不生效
问题描述
嗨,我正在做一个名为 todo-list 的项目。但似乎当我做填充、边距或定位时它不起作用。谢谢!
CreateArea.jsx -
import react from 'react';
//FINAL STEP: Create a database that store info about the todolist tasks!
function CreateArea() {
return (
<div className="mainbox">
<div className="inputdiv">
<input type="text" />
</div>
</div>
);
}
export default CreateArea;
style.css 的一部分 -
.mainbox {
width: 300px;
height: 650px;
background-color: #f5ba13;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3);
border-radius: 35px;
padding-left: 300px;
margin: 20px auto;
}
它看起来像这样 - 链接到图片
解决方案
如果要使用left, top, right and bottom
需要更改默认位置的属性,即静态,则可以使用绝对或相对。如果您选择absolute
需要将父 div 设置为相对位置,否则,您的元素将相对于<body>
.
使用绝对位置的示例:
.mainbox {
position: relative
width: 300px;
height: 650px;
background-color: #f5ba13;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3);
border-radius: 35px;
padding-left: 300px;
margin: 20px auto;
}
.inputdiv {
position: absolute;
top: 100px;
left: 200px;
}
推荐阅读
- c++ - 销毁二叉树中的节点
- javascript - 如何将数据从输入发送到 nextjs 中的两个不同的 api?
- python - 是否可以为“vista”主题的字段背景颜色和 ttk.Combobox 的其他部分自定义样式?
- excel - 使用电源查询将一张表中的两个相邻表转换为一张表
- javascript - 如何使用 jQuery 添加按钮?
- flutter - 如何在 Flutter 中正确设置组件大小的动画
- c++ - 如何从基类指针向量调用派生类函数?
- c++ - 动态库依赖于可执行文件(依赖倒置)
- python - 跳过从 Python 中的 CSV 文件读取一次的观察结果
- android-studio - 在有界区域内查找 HSV 矩阵列的平均 V 值