html - 如何为 div 提供正确的对齐方式
问题描述
这是我的代码,我需要显示一个页面,其中包含 3 个图像,其中一个在左侧,另外两个在右侧,但是所有图像都显示在同一行,它们没有显示以便我
项目清单
给了。请帮我解决这些问题。
.leftAlign {
float: left;
}
.rightAlign {
float: right;
margin: 10px;
}
.rightOrder{
float: right;
margin: 10px;
}
.primary-button {
background-color: #109bd5;
color: white;
}
<div class="about-content">
<h4 mat-dialog-title>Hello World</h4>
<div mat-dialog-content>
<div class='leftAlign'>
<h4>IMAGE1</h4>
<img src="assets/images/image1.png">
</div>
<div class='rightAlign'>
<h4>IMAGE2</h4>
<img src="assets/images/image2.png">
</div>
<div class='rightOrder'>
<h4>ICON</h4>
<img src="assets/images/icon_img.png">
</div>
</div>
<div mat-dialog-actions align="end">
<button mat-button mat-dialog-close class="mat-button primary-button">close
</button>
</div>
</div>
解决方案
<div style="display:flex;justify-content:space-between;">
<div>
<!-- This will be left aligned -->
<img src="https://via.placeholder.com/150?text=1" alt="image 1">
</div>
<div>
<!-- This will be right aligned -->
<div>
<img src="https://via.placeholder.com/150?text=2" alt="image 2">
</div>
<div>
<img src="https://via.placeholder.com/150?text=3" alt="image 3">
</div>
</div>
</div>
请看看这个,如果你使用的是 Bootstrap,我会推荐使用它而不是提供内联样式。
推荐阅读
- python - 裁剪 X 射线图像以去除背景
- tensorflow - 如何在 LSTM 上使用 TPU?
- angular - Protractor 模块 protractor-retry 测试在桌面上运行时不会重新运行并得到 Microsoft JScript 编译错误
- sequelize.js - sequelize(和 sequelize-cli)queryInterface.createTable 在 PostgreSQL 上,PK id 类型为 UUID 和 defaultValue:Sequelize.DataTypes.UUIDV4 失败
- r - 如何组合具有相同行名但唯一值的小标题行?
- java - 无法通过 mqipt 使用来自 java mq 客户端的 1 个通道将消息并行发送到不同的队列
- c# - C# Nullable:如何从 Dictionary 构建 FormUrlEncodedContent
- bash - 如何将我从 curl -w $ {http_code} 获得的值分配给变量
- java - jackson xmlmapper 动态属性名称
- node.js - 如何在 AWS Elastic Beanstalk 中指定 Procfile 的路径?