我正在製作一個網站,並且我有一個母版頁。我已經在母版頁中設置了元素的寬度和高度,以適應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