2013-07-08 30 views
0

我是CSS新手,也是web開發新手。在Windows應用在Web頁面中錨定控件就像WinForm應用程序

控件呼籲錨的屬性,調整父容器時,你可以通過設置將進行尺寸調整,其控制的一部分。我正在尋找網頁中的相同屬性。

讓我提供了一個例子:

假設我們有一個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> 

只要注意該示例代碼是錯誤的,強制按鈕和標籤到一個新行。

感謝

回答

0

試試這個

<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> 
+0

它導致兩條線!我希望他們在同一行(只有一行)。 –

+0

float:left;寬度:85%; style爲文本框的div –

+0

設置爲85%,當頁面變小時,組件跳轉到第二行。 –

0

使用表的伎倆

<table style="width:100%"> 
    <tr> 
     <td style="width:100%"> TextBox Here </td> 
     <td style="width:1px"> label Here </td> 
     <td style="width:1px"> button Here </td> 
    </tr> 
</table> 
相關問題