asp:表格宽度百分比不起作用
我正在尝试让表格看起来正确。当我使用固定宽度时,表格的大小是我想要的......但是当我使用 % 时,它就像被忽略了。
这是代码:
<asp:Table ID="Times" runat="server" style="Width:100%;">
<asp:TableRow BackColor="YellowGreen">
<asp:TableCell Width="45%">
<asp:Image ID="imgImage" runat="server" />
</asp:TableCell>
<asp:TableCell Width="55%" >xxxxxx xxxx xxxx<br /><br />
8:xxxxxxxx xxxxx xxxxxxxx<br />
xxxxxxxxx x xxxx<br />
xxxxxxx xxxxxxxxxx xxxxx</asp:TableCell>
</asp:TableRow>
</asp:Table>
我做错了什么?
VS 2010、vb.net、.net4、asp.net 应用程序
以下是呈现的标记:
<table id="ContentPlaceHolder1_Times" style="Width:100%;">
<tr style="background-color:YellowGreen;">
<td style="Width:45%"><img id="ContentPlaceHolder1_imgImage" src="Images\SlideShow\default\church.JPG" /></td><td style="Width:55%">Sunday Service Times<br /><br />
8:45 Fellowship Time<br />
9:00 Sunday School<br />
10:15 Church Services</td>
</tr>
这是 aspx 代码。
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:Table ID="Times" runat="server" Width="100%">
<asp:TableRow BackColor="YellowGreen">
<asp:TableCell Width="45%">
<asp:Image ID="imgImage" runat="server" />
</asp:TableCell>
<asp:TableCell Width="55%" >Sunday Service Times<br /><br />
8:45 Fellowship Time<br />
9:00 Sunday School<br />
10:15 Church Services</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:Content>
母版页
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body background='<%=ResolveClientUrl("images\wood2.jpg")%>'>
<form id="form1" runat="server">
<div id="header" style="padding: 5px 5px 2px; text-align: center; width: 400px;">
<asp:Image ID="imgSCC" runat="server" ImageUrl="images\hdrpic.jpg" />
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" SiteMapProvider="Menu"
ShowStartingNode="false" />
<asp:Menu ....>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
I'm trying to get a table to look correct. When I use fixed width, the table is the size I'd like for it to be... but when I use %, it's like it's ignored.
Here is the code:
<asp:Table ID="Times" runat="server" style="Width:100%;">
<asp:TableRow BackColor="YellowGreen">
<asp:TableCell Width="45%">
<asp:Image ID="imgImage" runat="server" />
</asp:TableCell>
<asp:TableCell Width="55%" >xxxxxx xxxx xxxx<br /><br />
8:xxxxxxxx xxxxx xxxxxxxx<br />
xxxxxxxxx x xxxx<br />
xxxxxxx xxxxxxxxxx xxxxx</asp:TableCell>
</asp:TableRow>
</asp:Table>
What am I doing wrong?
VS 2010, vb.net, .net4, asp.net app
Here is the markup that is rendered:
<table id="ContentPlaceHolder1_Times" style="Width:100%;">
<tr style="background-color:YellowGreen;">
<td style="Width:45%"><img id="ContentPlaceHolder1_imgImage" src="Images\SlideShow\default\church.JPG" /></td><td style="Width:55%">Sunday Service Times<br /><br />
8:45 Fellowship Time<br />
9:00 Sunday School<br />
10:15 Church Services</td>
</tr>
and here is the aspx code.
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:Table ID="Times" runat="server" Width="100%">
<asp:TableRow BackColor="YellowGreen">
<asp:TableCell Width="45%">
<asp:Image ID="imgImage" runat="server" />
</asp:TableCell>
<asp:TableCell Width="55%" >Sunday Service Times<br /><br />
8:45 Fellowship Time<br />
9:00 Sunday School<br />
10:15 Church Services</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:Content>
the master page
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body background='<%=ResolveClientUrl("images\wood2.jpg")%>'>
<form id="form1" runat="server">
<div id="header" style="padding: 5px 5px 2px; text-align: center; width: 400px;">
<asp:Image ID="imgSCC" runat="server" ImageUrl="images\hdrpic.jpg" />
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" SiteMapProvider="Menu"
ShowStartingNode="false" />
<asp:Menu ....>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
Width="100%"
而不是style="width=100%;"
效果很好(最终它会做同样的事情)您指的是什么分辨率
当您说固定宽度看起来不错
百分比
很好当您希望页面在各种分辨率下看起来正确时,works great if
Width="100%"
instead ofstyle="width=100%;"
(eventually it does the same thing)What resolution are you referencing when you say fixed width looks good
percentage
is good when you want your page to look correct @ various resolutions