2013-07-01 60 views
0

我已經將css樣式表應用到了我的視圖,並且在我查看它時沒有渲染。有什麼問題就在這裏:CSS @ Styles.Render沒有渲染樣式表

編輯:在Firefox 17部作品,不IE10工作(?是與我的兼容性視圖不知道如何解決)

站長:

@using System.Web.Optimization 

<!DOCTYPE html> 

<html> 
<head> 
    <meta name="viewport" content="width=device-width" /> 
    <title>User_Master</title> 
    @Styles.Render("~/Content/Styles.css") 
</head> 
<body> 
    <header> 
     <p>header</p> 
    </header> 
    <nav> 
     @Html.Partial("~/Views/Shared/User_Nav.cshtml") 
    </nav> 
    <section> 
     @RenderBody() 
    </section> 
</body> 
</html> 

Styles.css中

header { 
    border-color: #0094ff; 
    border-bottom-right-radius:10px; 
    border-top:hidden; 
    border-left:hidden; 
    border-bottom:solid; 
    border-right:solid; 
    box-shadow:2px 2px; 
} 

首頁

@{ 
    ViewBag.Title = "Home"; 
    Layout = "~/Views/Shared/User_Master.cshtml"; 
} 

<h2>Home</h2> 
+0

您在'@ Styles.Render(〜/ Content/Styles.css「)中缺少一個雙引號';我不確定這只是您的問題中的拼寫錯誤,或者它是您的實際問題 – vee

+0

Nah,在問題中輸入錯誤 – Neeta

回答

0

這個問題似乎有兩個部分。


CSS問題的

一部分是無效的CSS相關。例如,border-top是樣式,寬度和顏色的組合速記聲明:

border-top: [width style colour]

考慮到這一點,我會如下改變你的CSS:

header 
{ 
    border: 2px solid #0094ff; /* width style colour */ 
    border-bottom-right-radius: 10px; 
    border-top-style: hidden; 
    border-left-style: hidden; 
    box-shadow: 2px 2px 0px #000; /* x-offset y-offset blur colour */ 
} 

IE /兼容模式

如果IE通過兼容性ty模式下,您可能使用IE8(或更早版本)引擎進行渲染。不幸的是,這些不理解HTML5,所以諸如<header />元素和border-radiusbox-shadow等CSS聲明被忽略。有幾件事可以嘗試解決:

  1. <meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1" />添加到您的<head />元素。這會告訴IE你想使用最新的渲染引擎。有關詳細信息,請參閱this page
  2. 包括一個JavaScript庫,如HTML5Shiv(它也包含在出色的Modernizr庫中)。這允許舊版本的Internet Explorer至少識別HTML5元素,如<header />。請注意,它不會添加CSS3支持;像border-radius這樣的東西將不起作用,但至少你會得到正常的邊界。
+0

在我等待答案時,我已經修復了你的問題,但仍然無法正常工作IE /兼容模式第1點爲我解決了問題。你介意解釋/重定向到一些資源,它解釋瞭如何構建元標記的http-equiv和內容attribs? – Neeta

+1

這可能解釋元標記好一點:http://stackoverflow.com/questions/6771258/whats -the差-IF-元HTTP的當量-X-UA兼容的內容,即邊緣#答案-6771584 – vee