如何對齊div以便兩個標籤具有相同的寬度並右對齊,並且兩個內容都在相同的位置開始。有些人建議float
,但我不推薦浮動內容。有沒有這樣做的靈活方式。flex上的div文本對齊
<!DOCTYPE HTMML>
<html>
<body>
<div>
<div style="display: flex; flex-direction:row;">
<div style="align: right; background: blue">
Long label:
</div>
<div style="text-align: left; background: green">
This is the content
</div>
</div>
<div style="display: flex; flex-direction:row;">
<div style="align: right; background: blue">
label:
</div>
<div style="text-align: left; background: green">
This is the content
</div>
</div>
</div>
</body>
</html>
即使我給固定的寬度其不響應它。 – anivas