hi
I'm trying to set the appearance of a Login web control, but I'm having quite a few problems. As far as I can tell, I've set everything correctly, but for some reason control still isn't displayed correctly:
a) The width of the two TextBox controls ( with IDs UserName and Password ) should be equal to 70% of table's width, but it isn't, even though I've set their width attributes. Any idea why that is?
b) If table cells containing lblPassword and lblPassword controls have their text-align property set to center, then lblPassword and lblPassword overflow. Why is that?
<div id="loginbox">
<asp:Login ID="Login1" runat="server" Width="100%" FailureAction="RedirectToLoginPage"
RememberMeSet="false">
<LayoutTemplate>
<table>
<tr>
<td style="padding:6px;text-align:center;">
<asp:Label ID="lblUserName" Width="30%" runat="server" Text="UserName "></asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" Width="70%" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding:6px;text-align:center;" >
<asp:Label ID="lblPassword" Width="30%" runat="server" Text="Password "></asp:Label>
</td>
<td>
<asp:TextBox ID="Password" Width="70%" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
#loginbox
{
position: absolute;
top: 16px;
right: 30px;
width: 180px;
height: 80px;
padding: 2px 2px 2px 2px;
font-size: 9px;
margin:0px;
}
much appreciated
EDIT:
This code is telling the browser that the span should be 70% smaller than the TD. The only element telling the TD what width it should be is a span, that span wants to be 70% smaller than the TD. So the TD just ends up using the text inside the span to tell how big it should be.
Then that’s different behavior than my example with textboxes, since as far as I understand your argument, in the above case the span element ( ie text inside a span ) was rendered using its default width, while TD adapted its width to be 70 % bigger than span’s default width?! But in case of TextBox controls, the width used for TextBoxes controls wasn’t their default width D, but instead their width was also reduced ( let’s call this reduced TextBox’s width W ), so TD wasn’t 70% bigger than D, but instead TD was 70% bigger than W ( where W < D )?! But how did browser come up with width W?
Now the TD on the right wants to be 70% of the width of the row (TR) which is the same width as the TABLE. In this case, the TD on the left determines the end size of the table, since its contents should make up 30% of the width of the table.
Why do you say the element on the left determines the size of the table? Don’t both the left and the right TDs determine the final size of a table?
thanx mate
SECOND EDIT:
a) I understand that the two cells should have sizes relative to each other, but I’m not sure I understand how 55px / 30% * 70% gives us the correct result? If anything, shouldn’t formula be 55 * 100% / 30 % ( here 55px represents 30% of right cell’s width) or 55 * 100% / 70% ( here 55px represents 70% of left cell’s width) ?!
b) What if the span elements in these two cells didn’t have equal widths? How would browser then calculate the width of the two cells?
c) I assume that if table had a width specified, then the widths of two cells wouldn’t be relative to each other, but relative to the width of the table?
Thanx mate
THIRD EDIT:
A) As far as I understand your explanation, the browser calculates the widths of the two cells in the following way:
The left cell has its width set to 30% of some value and formula55px * 100% / 30% = 183px* tells us that the width of a left cell ( which is 55px ) is 30% of 183px.
That also means that right cell has width equal to 70% of 183px, which is 183 * 70% / 100% = 124px. Thus the widths of left and right columns are 30% of 183px and 70% of 183px, respectively.
B) But I thought that the term you used in your explanation --> “widths of left and right cells should be relative to each other” <-- meant that browser should compute the widths in one of the following two ways:
a) the width of left cell should be 30% of right cell’s width. Since left cell has a width of 55px, where 55px represents 30% of right cell’s width, then the width of right cell would be 55px * 100% / 30% = 183 px
OR
b) the width of right cell should be 70% of left cell’s width. Since right cell has a width of 55px, where 55px represents 70% of left cell’s width, then the width of left cell would be 55px * 100% / 70% = 78px