html - 是否可以对齐
使它们均匀?
问题描述
我的意思是第二列甚至在每个类别中。我的代码如下所示:
<div class="prod-card-fields-static col-5">
{[if_manufacturer]}
<p class="m-0">{[lang_manufacturer]}: <b>{[manufacturer]}</b></p>
{[/if_manufacturer]}
{[if_custom_field_1]}
<p class="m-0">{[custom_field_1_name]}: <b>{[custom_field_1]}</b></p>
{[/if_custom_field_1]}
{[if_custom_field_2]}
<p class="m-0">{[custom_field_2_name]}: <b>{[custom_field_2]}</b></p>
{[/if_custom_field_2]}
{[if_custom_field_3]}
<p class="m-0">{[custom_field_3_name]}: <b>{[custom_field_3]}</b></p>
{[/if_custom_field_3]}
{[if_category_1]}
<p class="m-0">{[category_1_name]}: <b>{[category_1]}</b></p>
{[/if_category_1]}
{[if_category_2]}
<p class="m-0">{[category_2_name]}: <b>{[category_2]}</b></p>
{[/if_category_2]}
{[if_category_3]}
<p class="m-0">{[category_3_name]}: <b>{[category_3]}</b></p>
{[/if_category_3]}
</div>
</div>```
解决方案
您可以将p
标签包装在 a 中div
并flexbox
为您的div
.
.labelWrapper {
width: 50%;
display: flex;
justify-content: space-between;
}
<div class="prod-card-fields-static col-5">
<div class="labelWrapper">
<p class="m-0">lang_manufacturer: </p>
<p>manufacturer</p>
</div>
<div class="labelWrapper">
<p class="m-0">lang_manufacturer: </p>
<p>manufacturer</p>
</div>
<div class="labelWrapper">
<p class="m-0">lang_manufacturer: </p>
<p>manufacturer</p>
</div>
</div>
推荐阅读
- node.js - nyc npm run test 路径中有空格的问题
- nativescript - 如何在 Webview 中禁用滚动?
- java - 无法在 Hybris 中检索 bean 值
- vagrant - Prestashop 安装宅基地指南
- java - 使用 Glassfish 打开与 Microsoft SQL 的连接时崩溃
- node.js - 无法在占位符内使用 EJS 显示数据
- javascript - 在Angular 6中按嵌套值过滤HTTP JSON响应
- spring-boot - 如何使 Spring Boot 应用程序可在 TomEE 7.x 上部署?
- xamarin.ios - 在 Xamarin.iOS 中以编程方式关闭 UIAlertView
- c# - 一对一或零实体框架 Fluent API