html - Angular : Bootstrap - 如何在从其他组件调用时在组件中使用全高?
问题描述
在我的 Angular 应用程序中,我有两个组件:(app.component
始终默认创建)和login.component
.
我login.component
从app.component
. 但问题是在登录组件内部设计某些东西时我没有得到完整的高度。结果,当我从 调用login.component
时app.component
,设计的高度比我预期的要低得多。
那么当我从第一个组件调用它时,如何在我的第二个组件上使用全高呢?
app.component.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" >Home</a>
</li>
<li class="nav-item">
<a class="nav-link" >Create</a>
</li>
<li class="nav-item">
<a class="nav-link" >Display</a>
</li>
<li class="nav-item">
<a class="nav-link" >Report</a>
</li>
</ul>
</nav>
<router-outlet></router-outlet>
</body>
</html>
login.component.html
<div style="height: 100%; display: flex; align-items: center; justify-content: center; background-color: #44739d; ">
<div class="card" style="width: 18rem; height: 100%;">
<div class="card-body">
<form>
<div class="form-group">
<input type="text" placeholder="Username / Email" class="form-control" id="exampleInputEmail1">
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control" id="exampleInputPassword1">
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Remember me</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
截屏 :
笔记:
1)如您所见,我将整个页面标记为蓝色,我的第二个组件(登录)仅使用页面的上部
2)在我的第二个组件中,我使用 style="height:100%" 仍然无法正常工作。(在此之后,我感觉第一个组件的某些东西挡住了第二个组件的高度,但请看下一点)
3)所以我正在检查我的第一个组件,在 body 中只有一个bootstrap nav-bar
和一个angular <router-outlet>
。nav-bar
没关系,它应该在上面,不应该影响我的设计。我也试过删除它,问题是一样的。现在我调用<router-outlet>
?
应该有一个简单的修复,我错过了什么?
[顺便说一下,没有添加.ts代码(内置代码除外),我只是HTML
一个ng-bootstrap
人设计]
解决方案
只需在 HTML 中添加一个容器或容器流体类。
<div class="container-fuild">
<router-outlet></router-outlet>
</div>
或者您可以将容器或容器流体添加到您的身体,如下所示
<body>
<div class="container-fluid">
<--- your content here --->
</div>
</body>
参考: https ://getbootstrap.com/docs/4.6/layout/overview/#containers
推荐阅读
- r - 查找某个数字属于哪一行
- jquery - 清除textbox1时如何清除textbox2的值(在选择textbox1的自动完成时动态添加)
- node.js - 如何禁用开发人员工具中源选项卡中的编辑选项?
- node.js - 使用nodejs通过REST将文件发送到githib时出现403错误
- r - 如果数据很大(即 2gb),我如何在 R 中看到整个数据
- javascript - 单击提交按钮时重新加载相同的选项卡,并在单击选项卡时加载数据或打开视图
- android - 拍照,保存到图库并在 Android 中选择 Uri
- angular - 拒绝加载图像,因为它违反了以下内容安全策略指令(favicon)
- react-native - react-native 链接没有在 android 的 react-native 项目中链接我的包
- azure - ARM 模板:查找用户对象 ID