我正在制作一个网站,并且我有一个母版页。我已经在母版页中设置了元素的宽度和高度,以适应Firefox浏览器,所以当我打开我的页面时它工作正常,但只要我转移到Chrome或Opera或IE,页面不适合整个浏览器区域。该页面比浏览器的可视区域更小(显示空格)或更大(滚动条),功能显而易见,因为我已经对宽度和高度进行了硬编码以适合Firefox。我也知道,当我在Firefox中打开相同的页面但在别人的电脑中时,至少会出现一些失真(由于不同的分辨率)。如何在asp.net中设置元素的大小与浏览器的大小相同
有没有人有一个javascript/c#代码,我可以用它来动态地设置一个元素的大小,作为它打开的浏览器?以下是我的母版页的html。我已经突出显示了我为Firefox设置的粗体代码。
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" 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 id="Head1" runat="server"> <title>Untitled Page</title> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form id="form1" runat="server"> <div> <table width="1330" cellspacing="1" cellpadding="1" border="0" align="left"> <tr> <td width="5" rowspan=2> </td> <td width="95"> </td> <td align="center" width="1230"><img src="Images/dset01titleds.gif" width=392 height=63 border=0 alt="Blank Title w/ Drop Shadow"></td> </tr> <tr> <td align="center" valign="top" width="100"> <a href="http://"><img src="Images/dset01b01.gif" width=114 height=30 border=0 alt="Home"></a><br> <a href="http://"><img src="Images/dset01b02.gif" width=114 height=30 border=0 alt="About Us"></a><br> <a href="http://"><img src="Images/dset01b03.gif" width=114 height=30 border=0 alt="Products"></a><br> <a href="http://"><img src="Images/dset01b04.gif" width=114 height=30 border=0 alt="Services"></a><br> <a href="http://"><img src="Images/dset01b05.gif" width=114 height=30 border=0 alt="Order"></a><br> <a href="http://"><img src="Images/dset01b06.gif" width=114 height=30 border=0 alt="Contact"></a><br> <a href="http://"><img src="Images/dset01b07blank.gif" width=114 height=30 border=0 alt="Blank"></a><br> </td> <td valign="top" width="1230px" style="height:440px"> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </td> </tr> <tr style="height:10px"><td colspan=3 align=center>bottom of the screen</td></tr> </table> </div> </form> </body> </html>
我知道为此添加服务器端代码并不是一个好主意,但为了它而添加了它。至于宽度和高度= 100%,我试过了,但它没有工作,但会再试一次。但是JavaScript会创造奇迹。 – samar
当然,您必须对每个元素应用100%身体 - 格 - 表 - tr等... –
好吧,会试试这个.. !! – samar