asp.net - 像 WinForm 应用程序一样在网页中锚定控件

标签 asp.net .net css web

我是 CSS 的新手,也是网络开发的新手。

windows应用程序中的控件有一个属性叫做anchor,可以设置在调整父容器大小时调整控件的哪一部分。我在网页中寻找相同的属性。

举个例子:

假设我们有一个 textbox , 一个 button和一个 label连续,我的问题是如何给 labelbutton 固定大小(例如 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/

相关文章:

c# - ASP.NET SQL 插入错误

c# - 从地址中提取邮政编码

c# - 如何禁用 WPF ListBox 中的水平滚动?

javascript - 日期选择器快捷方式,例如 1m、1y、1d

c# - PhoneGap 开发 ASP.NET MVC 应用程序

.net - 无法隐式转换类型 'System.Linq.IQueryable<Anon>to ' System.Linq.IQueryable<Report>存在显式转换,是否缺少强制转换?

css - 文字不环绕图像

javascript - 固定位置导航栏不起作用

javascript - 仅 float 图像 css

asp.net - 将 ASP.NET vNext 应用程序部署到 Azure 云服务