2014-06-25 44 views
0

我有一個asp.net形式,其中我想一些字體設置適用於通過css.This一個文本框是我在我的CSS:爲什麼css沒有被應用到我的網頁?

body 
{ 

} 

@font-face { 
    font-family: 'Lohit Devanagari',serif; 
    src: url('http://fonts.googleapis.com/earlyaccess/lohitdevanagari.css'); 
    font-weight: normal; 
    font-style: normal; 
} 

.txtQues 
{ 
    font-family: 'Lohit Devanagari',serif; 
    font-size:14px; 
    background-color:Yellow; 
} 

下面是我的網頁源代碼,其中的一部分我加入的CSS頁面:

<head> 
<title>Question Master</title> 
<link href="../FontSettings.css" rel="stylesheet" type="text/css" /> 
<meta name="google-translate-customization" 
content="3280487709591956- dc3fc45d489f056a-g5378ebab0cbcd0a4-12"/> 
</head> 

文本框:當我申請的CSS的形式

<asp:TextBox ID="txtQuestion" runat="server" Height="101px" TextMode="MultiLine" Width="627px" meta:resourcekey="txtQuestionResource1" EnableTheming="True" 
ontextchanged="txtQuestion_TextChanged" CssClass="txtQues"></asp:TextBox> 

,我看到的顏色變化文本框在設計窗口中,它告訴我正在應用css,但是當我在瀏覽器上運行代碼時,我發現文本框的顏色都不會改變,字體也不會改變。善良的幫助我,讓我知道我哪裏錯了。

+1

我們可以看到您試圖設計樣式的元素的HTML嗎? – Turnip

+0

我假設你正在嘗試使用'txtQues'類的風格元素? – Eilidh

+1

你有正確的路徑包括爲CSS?..鏈接href =「../ FontSettings.css」? – Sudheer

回答

1

刪除@font-face並導入該文件。 CSS已經使用了font-face。嘗試:

@import url("http://fonts.googleapis.com/earlyaccess/lohitdevanagari.css"); 
body 
{ 

} 
.txtQues 
{ 
    font-family: 'Lohit Devanagari',serif; 
    font-size:14px; 
    background-color:Yellow; 
} 
+0

這是行不通 – TVicky

+0

我似乎無法得到它的工作..我做了一個小提琴玩:http:///jsfiddle.net/7trE4/1/ –

0

在下面的代碼中,刪除「EnableTheming」或使其爲false。

<asp:TextBox ID="txtQuestion" runat="server" Height="101px" TextMode="MultiLine" Width="627px" meta:resourcekey="txtQuestionResource1" EnableTheming="True" ontextchanged="txtQuestion_TextChanged" CssClass="txtQues"></asp:TextBox> 

也嘗試在CSS中保留重要的樣式,如下所示。

.txtQues 
{ 
font-family: 'Lohit Devanagari',serif !important; 
font-size:14px !important; 
background-color:Yellow !important; 
} 
+0

仍然無法正常工作。 – TVicky

+0

更新了我的答案。也試試這個。 –

+0

那麼@蘇雷什,我是否需要保持啓用主題真或假 – TVicky

相關問題