【发布时间】:2021-06-06 21:27:08
【问题描述】:
我正在使用 create-react-app 构建一个简单的反应页面,但布局有问题。我的组件嵌套在App中,仅限于页面顶部。
这是一张图片,显示了元素的位置和我的组件树:
// 应用程序
html, body {
margin: 0;
padding:0;
}
//容器
html, body {
margin:0;
padding:0;
}
//标题
.loan-header {
display: flex;
justify-content: flex-end;
align-items: center;
background: white;
width: 100%;
border: 0;
border-radius: 3;
box-shadow: 0 3px 5px 2px rgba(180, 180, 180, .3);
color: white;
height: 60px;
}
//应用容器
.loan-application-container {
display: flex;
justify-content: space-between;
align-items: center;
background: white;
border: 0;
border-radius: 3;
box-shadow: 0 3px 5px 2px rgba(180, 180, 180, .3);
color: #005350;
height: 100px;
width: 75%;
top: 100px;
}
.applications {
font-size: 12px;
padding: 2;
display: inline-flex;
align-items: baseline;
width: 100%;
height: 50%;
border: 0.32px;;
border-radius:3;
justify-content:space-between;
font-size: 1vw;
border-color: black;
}
.view-btn {
height: 30;
width: 10%;
background: #005350;
font-size: 1vw;
color: white;
}
p {
font-family: 'Gill Sans';
font-weight: bold;
font-size: 1vw;
width: 30%;
color: #005350;
}
【问题讨论】:
-
你使用弹性盒子吗?
display: block?向您发布与您的元素相关的 CSS... -
添加了 CSS @zergski
-
@zergski 非常感谢。确实让它到达了顶部的中心。还有一个问题,我如何将那张申请卡放在中心,我似乎无法将它与标题分开。
-
别担心,乐于助人!如果您接受我的回答,我将不胜感激。 =) 你的意思是垂直居中相同的元素吗?您在上一个问题中使用了什么解决方案?
-
我使用了快速修复——我正在制作一个页面,其中两个“应用程序卡”位于页面中心。
标签: javascript css reactjs user-interface frontend