2015-04-19 27 views
0

我在asp.net中有一個母版頁,它將包含其他頁面內容拋出ContentPlaceHolder。我希望在使用內容ContentPlaceHolder的頁面中顯示的內容無關緊要的情況下,在底部使用CSS的母版頁中有一個頁腳。如何使頁腳粘在asp.net頁面上?

這是我的母版頁:

<body> 
<form id="form1" runat="server" style="height:100%;"> 
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"> 
    <Scripts> 
     <asp:ScriptReference Path="Scripts/jquery-1.11.2.min.js" /> 
     <asp:ScriptReference Path="Scripts/CommonMethods.js" /> 
     <asp:ScriptReference Path="Scripts/CommonProperties.js" /> 
     <asp:ScriptReference Path="http://code.jquery.com/ui/1.10.4/jquery-ui.js" /> 
     <asp:ScriptReference Path="Scripts/jquery.watermark.min.js" /> 
    </Scripts> 
</asp:ScriptManager> 
<div id="header"> 
    <h1> 
     SABIS® Educational Systems INC. 
    </h1> 
</div> 
<div id="nav"> 
</div> 
<div id="section"> 
    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> 
    </asp:ContentPlaceHolder> 
</div> 
<div id="footer"> 
    Copyright © Sabis.net 
</div> 
<asp:ContentPlaceHolder ID="cpClientScript" runat="server"> 
</asp:ContentPlaceHolder> 
</form> 

我試過很多的CSS,但沒有正常工作對我來說始終是一個流動!!。

回答

2

好的,我認爲你首先將一些東西混合起來:ASP對瀏覽器顯示頁面的方式沒有影響。這是因爲ASP是輸出純HTML的服務器端語言。然後將這個HTML發送到您的瀏覽器,以及鏈接到(CSS,JavaScript,圖像...)的任何資產。

所以這就是CSS來的地方.CSS用於向HTML添加樣式。所以你完全正確的認爲CSS是獲得你描述的行爲的方式。具體方法如下:

div#footer{ // Add the style below to the div with ID "footer" 
    position: fixed; // Set the position to "fixed" to the screen 
    bottom: 0px; // The fixed position should be 0px from the bottom of the screen 
    width: 100%; // Optional, this stretches the div across the width of the screen 
} 

您可以把這塊CSS的在你的頁面的<head>一個<style>標籤,但它通常是更好地把它放在一個單獨的.css文件,並鏈接到它的<head>該頁面,像這樣:

<link rel="stylesheet" href="path/to/stylesheet.css"> 

補充閱讀:here's a getting started guide about CSS stylesheets.

+0

感謝這真棒介紹。我確實知道你在說什麼,但可能是我沒有很好地解釋自己,這仍然是我第一次使用網絡。任何方式您提供的CSS工作就像我想要的一樣。謝謝。 – Baso