我有一个 DIV 元素:
<div style="background-color:red">This is a test
<label>ID:</label>
<asp:TextBox runat="server"><asp:Textbox>
</div>
我需要在左侧显示“这是一个测试”,但在右侧显示标签和文本框。
我试过了
margin:right 0px;
但这并没有帮助。
也试过 Float:right 但这产生了奇怪的结果。
最佳答案
添加一个div来包裹标签和输入,并使用float
:
.input-group {
float: right;
}
<div style="background-color:red">This is a test
<div class="input-group">
<label>ID:</label>
<input type="text" />
</div>
</div>
关于html - 使 Html 标签显示在 Div 元素的右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33633970/