Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Master page not referencing CSS properly?

Status
Not open for further replies.

wolff123

Technical User
Jul 22, 2009
3
GB
I’ve been trying to get the following to work to keep the footer at the bottom of the page. I’ve had this from here and it works well. I can’t get it to keep the footer at the bottom when using master pages. I know that this may be because I’m new to using master pages. From what I can make out, the properties of the "body" tag do not seem to apply to the asp placeholder. Any ideas on what I could be doing wrong?


Here is my Master page:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MJT Footer at bottom.master.cs" Inherits="styles_MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns="<head runat="server">
<title>Untitled Page</title>
<link href="styles/MJTFooterAtBottom.css" rel="stylesheet" type="text/css" />


<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>


</head>
<body>
<form id="form1" runat="server">

<div id="container">
<div id="header"></div>
<div id="body">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="footer"></div>

</div>
</form>
</body>
</html>


The style sheet is as follows:

html,
body {
margin:0;
padding:0;
height:100%;
}
#container {
min-height:100%;
position:relative;
}
#header {
background:#ff0;
padding:10px;
}
#body {
padding:10px;
padding-bottom:60px; /* Height of the footer */
}
#footer {
position:absolute;
bottom:0;
width:100%;
height:60px; /* Height of the footer */
background:#6cf;
}



The content page is as follows:

<%@ Page Language="C#" MasterPageFile="~/MJT Footer at bottom.master" AutoEventWireup="true" CodeFile="MJT Footer at bottom.aspx.cs" Inherits="_Default" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


Test Content MJT


</asp:Content>
 
something like
Code:
<link href="[COLOR=blue]/[/color]styles/MJTFooterAtBottom.css" rel="stylesheet" type="text/css" />
or
Code:
<link href="[COLOR=blue]~/[/color]styles/MJTFooterAtBottom.css" rel="stylesheet" type="text/css" />

what you currently have is a relative link to the\ sub directory styles. this works if your webform is on the root. but if your webform is located in a sub directory (/sub/default.aspx) then it would look for the style sheet here (/sub/styles/MJTFooterAtBottom.css).

to test the css is linked properly create an obvious css style like making the background color of the body red. this proves the css is linked and the footing problem is related to the css configuration.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Thanks. The referencing to the .CSS file is working OK as a result of where I've positioned the files, as you're suggesting.

The issue I think is the '#body' tag is not applying properly to the aspx content page. As the code shows currently, I've put the #boby div around the asp placeholder in the master page. I think this is where it is going wrong but havn't a clue how to fix it?

Cheers
 
if may also be the id itself, "body". body is the keyword for html. try changing the id to "content" or "main-part" or something like that.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Good point - it doesn't make a difference though!

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top