2013-02-07 2 views
1

site.css 파일에서 css 클래스에 액세스 할 수 없습니다. 이러한 클래스를 개별보기 (.cshtml) 파일에 기록하면 액세스 할 수 있습니다. 코드 세부 정보는 아래와 같습니다 : #mask { 위치 : 절대; }.css 클래스를 .cshtml에 사용하는 방법

 /* 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? 

답변

0

다음은 기본 옵션입니다 - 당신이 당신의 문서에 스타일 태그를 추가합니다.

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

당신이 번들을 사용하는 경우가 대신 번들 장소 :

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

그리고 당신은 마스터 레이아웃을 사용하는 경우 마지막으로, 즉으로 이것을 넣어하는 가장 좋은 장소를 그러면 모든 페이지에 적용됩니다.

업데이트

당신이 ID를 대상으로하는 경우, 당신은 오히려 클래스 인 점,보다, #을 사용합니다.

#Add-popup 
    { 
     background: white; 
    } 

    img.btn_close 
    { 
    float: right;  
    } 

또한 하나의 답을 방문 할 수 있습니다 : 당신은 내가 u는 내 코드에 언급 된 섹션을 배치해야합니까 어디에 내 codem에 따라 의미 변경됩니다 알려 주시기 바랍니다 수 있습니다 vishal..but how to refere CSS in CSHTML file?

+0

감사합니다. – user1802212

+0

헤더에서 CSS 파일을 호출합니다. 추가 정보 : http://stackoverflow.com/questions/10279873/dynamic-stylesheets-using-razor –

+0

vishal 제 코드에 변경 사항을 제안하십시오 .i uint는 링크 u를 이해하지 못합니다. – user1802212

관련 문제