开发者

inline css mvc issue

开发者 https://www.devze.com 2023-02-03 04:58 出处:网络
I am trying to put inline css into an mvc page which inherits from a master page. I want to do this because this css is page specific and I feel it shouldn\'t go into a site wide file. What is the bes

I am trying to put inline css into an mvc page which inherits from a master page. I want to do this because this css is page specific and I feel it shouldn't go into a site wide file. What is the best way of doing this. My failed attempt is below. Nothing on the site will recognize testTwo styling. Thank you

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
        .test
        {
        }
       开发者_StackOverflow .testTwo *
        {
            float: left;
            padding: 5px;
            border: 2px solid gray;
            margin: 3px;
        }
    </style>
</asp:Content>


missing the opening <style> tag? bad copy-paste, not the issue


Where is this ContentPlaceHolder at in your MasterPage?

Often times the TitleContent ContentPlaceHolder is inside the <head> tag within the <title> element like so:

<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>

Is this the case? If so, those styles will not be interpreted since browsers won't recognize the styles within <title><style>..</style></title>


I would suggest updating your MasterPage like this:

<head>
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
    <link.... />
    <link.... />
    <asp:ContentPlaceHolder ID="StylesheetContent" runat="server" />
    <script.... />
    <script.... />
    <asp:ContentPlaceHolder ID="ScriptContent" runat="server" />
</head>


Where is your opening

<style type="text/css">

?

0

精彩评论

暂无评论...
验证码 换一张
取 消