[英]How to make the first element aligned to the right and the other elements in the left of that first?
I have two HTML elements: label and span inside a div I want the label aligned to the right and the span in the left of the labe;我有两个 HTML 元素: div 中的 label 和 span 我希望标签向右对齐,span 在标签左侧;
But this is what I have:但这就是我所拥有的:
this is the HTML and CSS code:这是 HTML 和 CSS 代码:
.barcode-pdf-body div { text-align: right; border-color: transparent; margin-top: 0; font-size: 10px; margin-bottom: 9px; } .barcode-pdf-body div label { margin-left: 5px; font-weight: bold; font-family: "myFont"; } .barcode-pdf-body div span { font-family: "myFont"; }
<div> <label> {% trans 'constraint_number' %}: </label> <span> {{ correspondence.number }} </span> </div>
If you can change only CSS file, check code below:如果您只能更改 CSS 文件,请检查以下代码:
.barcode-pdf-body div { text-align: right; border-color: transparent; margin-top: 0; font-size: 10px; margin-bottom: 9px; display: flex; } .barcode-pdf-body div label { margin-left: 5px; font-weight: bold; font-family: "myFont"; order: 2; } .barcode-pdf-body div span { font-family: "myFont"; order: 1; }
<div> <label> {% trans 'constraint_number' %}: </label> <span> {{ correspondence.number }} </span> </div>
please try it like this:请像这样尝试:
div label {
float:right;
}
div span {
float:left;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.