我是 CSS 的新手,也是网络开发的新手。
windows应用程序中的控件有一个属性叫做anchor,可以设置在调整父容器大小时调整控件的哪一部分。我在网页中寻找相同的属性。
举个例子:
假设我们有一个 textbox
, 一个 button
和一个 label
连续,我的问题是如何给 label
和 button
固定大小(例如 100 像素)并制作 textbox
将空间填充到 100%。
代码片段可能是这样的:
<div>
<div style="float:left; width:100%;">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></div>
<div style="float:left; width:100px;">
<asp:Button ID="Button1" runat="server"></asp:Button></div>
<div style="float:right; width:100px;">
<asp:Label ID="Lbl1" runat="server"></asp:Label></div>
</div>
请注意示例代码是错误的,它强制按钮和标签进入新行。
谢谢
最佳答案
试试这个
<div>
<asp:TextBox ID="TextBox1" Width="75%" Style="float: left;" runat="server"></asp:TextBox>
<asp:Button ID="Button1" Text="test" Width="10%" Style="float: right;" runat="server">
</asp:Button>
<asp:Label ID="Lbl1" Text="test" Width="10%" Style="float: right;" runat="server"></asp:Label>
</div>
关于asp.net - 像 WinForm 应用程序一样在网页中锚定控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17519184/