Reputation: 4038
My html
<p class="ten_mat_hang">Tên mặt hàng:<b>Casio</b></p>
<p class="quoc_gia_ban">Nơi bán:<b>Japan</b></p>
<p class="khoi_luong">Khối lượng:<b>1kg</b></p>
returns
Tên mặt hàng:Casio
Nơi bán:Japan Khối lượng:1kgIt is not align well. I want "Casio", "Japan", "1kg" to align like below (dash chars are just for aligning purpose)
Tên mặt hàng: Casio
Nơi bán:_____Japan
Khối lượng:__1kg
And I can not use table. Is is possible to format like above using css? Thanks
Upvotes: 1
Views: 43
Reputation: 43895
Make a table by using:
display: table
and table-layout: fixed
display: table-cell
and display: table-row
Use ex
as the unit measurement in this case since you have a concern about text spacing. ex
= the width of 'x' So it's about the width of 1 char at your font.
section {
width: 30ex;
display: table;
table-layout: fixed;
}
div {
width: 20ex;
display: table-cell;
}
label {
display: table-cell;
}
article {
display: table-row;
}
<section>
<article>
<div>Tên mặt hàng:</div>
<label>Casio</label>
</article>
<article>
<div>Nơi bán:</div>
<label>Japan</label>
</article>
<article>
<div>Khối lượng:</div>
<label>1kg</label>
</article>
</section>
Upvotes: 1