1

I am unable to access the css classes from site.css file.But if i write these classes in my individual view(.cshtml) file then i am able to access them. Please suggest Code Details are as Below: #mask { position:absolute; }

        /* You can customize to your needs  */
        .Add-popup
        {
          background: white;
        }

        img.btn_close 
        { 
         float: right;      
        } 
        '
        i have above classes in CSS file            
        1) this is my _layout.cshtml

        '
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="utf-8" />
            <title>@ViewBag.Title</title>
            <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet"  type="text/css"/>
        </head>
        </html>
        '

        2) this is my view

        '
        @{   

            ViewBag.Title = "View";
            Layout = "~/Views/Shared/_Layout.cshtml";
        }
        @if (false)
        {
            <script src="../../Scripts/jquery-1.7.1-vsdoc.js" type="text/javascript"></script>
            <link type="text/css" href="../../Content/Site.css" rel="stylesheet"  />
            <script src="...../ui/jquery.ui.mouse.js"></script>
            <script src="...../ui/jquery.ui.draggable.js"></script>         
        }
        @if (User.IsInRole("Owner"))
        {
        <div id="box" class="Add-popup">                                <a href="#" class="close"><img src="../../Content/images/close_button.png" class="btn_close" title="Close Window" alt="Close" /></a> 
         </div>
        }

'
        still i am not able to access those classess from CSS file.

        please reply if anybody has solution?
user1802212
  • 53
  • 1
  • 2
  • 10

1 Answers1

0

Here is the basic option - you add a style tag to the of your document.

<link rel="stylesheet" href="site.css" type="text/css" />

If you are using bundles, you place the bundle there instead:

@Styles.Render("~/Content/css")

And finally, if you are using a master layout, that's the best place to put this as it will then apply to all your pages.

Update

If you are targeting an id, you use #, rather than the dot, which is for a class.

#Add-popup
    {
      background: white;
    }

    img.btn_close 
    { 
     float: right;      
    } 

Also you can visit one answer : how to refere CSS in CSHTML file?

Community
  • 1
  • 1
Vishal Bharti
  • 185
  • 1
  • 9