html - 对齐所有按钮正确位置的问题
问题描述
我使用 angular material(10.2.5) 工具栏组件,我想让我的三个按钮向右,但我不能
<mat-toolbar color="primary">
<mat-toolbar-row>
<h3 [style.color]="'white'">Portail admin</h3>
<div class="parent">
<div class="children right-children">
<div class="child"><a mat-flat-button >Liste des livres</a></div>
<div class="child"><a mat-flat-button >Ajouter un livre</a></div>
<div class="child"><a mat-flat-button >Deconnexion</a></div>
</div>
</div>
</mat-toolbar-row>
</mat-toolbar>
.parent {
display: flex;
width: 100%;
height: 100px;
align-items: center;
justify-content: space-between;
}
.children {
display: flex;
}
.child {
margin: 0 5px;
padding: 0 5px;
font-size: 10px;
color: #000;
}
任何想法 ?我想将我的三个按钮对齐到工具栏的左侧,但我真的做不到。
对于我的 html 和 css 代码,我使用了 flexbox css。
解决方案
回答
.parent {
display: flex;
width: 100%;
height: 100px;
align-items: center;
justify-content: space-between;
}
.children {
display: flex;
}
.child {
margin: 0 5px;
padding: 0 5px;
font-size: 10px;
color: black;
}
.right-children{
position:absolute;
right:0;
}
<mat-toolbar color="primary">
<mat-toolbar-row>
<h3 [style.color]="'white'">Portail admin</h3>
<div class="parent">
<div class="children right-children">
<div class="child"><a mat-flat-button >Liste des livres</a></div>
<div class="child"><a mat-flat-button >Ajouter un livre</a></div>
<div class="child"><a mat-flat-button >Deconnexion</a></div>
</div>
</div>
</mat-toolbar-row>
</mat-toolbar>
添加:
.right-children{
position:absolute;
right:0;
}
推荐阅读
- sql - 在列中查找日期的准确性并将其复制并根据日期值的准确性分配给日期列
- sql-server - 数据库 B 和 C 中表中的所有行,只有数据库 A 中表中的唯一行
- c++ - C++ UBSAN 对派生对象产生误报
- python-3.x - 从数据框中写入多个 CSV 文件
- c# - 如何在 Jobject 中搜索节点
- python - 熊猫将唯一日期显示为重复
- java - 在输入具有最大和最小日期的情况下,Selenium 测试日期输入有问题
- android - 将检测的 JUnit4 测试与 Target apk 组合成一个 apk
- regex - 在确认空字符串的同时分解字符串中的列表
- c# - .net mvc 角度应用程序中的 CORS 问题