<分区>
<分区>
我的目标很简单,将 p 标签粘贴到自定义 css 卡的右侧,使其粘贴到左侧非常简单。
custom-text {
margin-left: 30px;
}
问题是如何让 100 美元始终粘在右边? 假设美元的值(value)变为 5 美元,如何让它总是在右边?
我可以用
custom-text-right {
margin-left: 450px;
}
但是这个解决方案不能扩展到不同的值(我使用 bootstrap 只是为了您的信息)
HTML 部分:
<h4>Price: <span class="dollar">$3.15</span></h4>
最佳答案
你可以使用 flexbox 来做到这一点,使用 justify-content: space-between;
.card {
display: flex;
height: 500px;
width: 500px;
background: #000;
justify-content: space-between;
color: white;
padding: 30px;
box-sizing: border-box
}
<div class="card">
<span>Price:</span>
<span> $100</span>
</div>
关于html - 我如何在右侧粘贴 html 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43736092/