SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    only for one page css and .net

    Guys I am having below CSS in the head tag of an aspx file which I want to use only for one particular page in the site. If I put this code in master page in .net then it will be applied to all site pages which I do not want. How do I make the below css work only for one particular page. That page is having the body id = “mainpage”


    <style type="text/css">
    @media screen
    {
    * html
    {
    overflow-y: hidden;
    width:90%;
    z-index:-1000;
    }
    * html body
    {
    height: 84%;
    overflow:auto;
    margin:0px;
    z-index:-1001;
    }
    }
    table#header
    {
    margin-top:-90px !important;
    background-color:#FFF;
    z-index:1000;
    margin-left:0 !important;
    }

    .fixedelement
    {
    position:fixed !important;
    _position:relative !important;
    _top:0px !important;
    _z-index:5000;
    }
    </style>

    Html is –
    <div class="fixedelement"></div>

  2. #2
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If your master page has this:

    Code:
    <head runat="server">
        <title>Untitled Page</title>
        <asp:ContentPlaceHolder id="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    Any content page can put content in the header. I.e. a page like this:

    Code:
    <asp:Content ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
    ...
    </style>
    </asp:Content>
    can register its own styles.

    Another option is to use ScriptManager.RegisterClientScriptBlock to inject the script (through a string) from code or to inject a reference to an external css file (registering a link tag).

    A third option is to just put the <style> in front of whatever content you define in the content page. Although it may not be perfectly valid XHTML (styles should go in the header section) I believe that every browser out there will actually honor such a style element.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •