2011-05-19 27 views
3

我有多個網頁一起工作。他們大多數從一個主文件具有相同的CSS。我遇到的問題是,一個頁面需要CSS有點不同。這裏是我的意思是:從主頁中刪除網頁上的CSS

碩士CSS

.Close 
    { 
     position: relative; 
     top: 0px; /* Different */ 
     display: block; /* Different */ 
     margin: auto; /* Different */ 
    } 

.ArrowLeft 
{ 
    background-image: url(arrow_left.png); 
    border: 0 none transparent; 
    padding: 0 0 0 0; 
    position: relative; 
    top: 0px; 
    height: 37px; 
    width: 47px; 
    z-index: 10; 
    display: none; 
    background-color: transparent; 
    float: left; /* Different */ 
} 

.ArrowRight 
{ 
    background-image: url(arrow_right.png); 
    border: 0 none transparent; 
    padding: 0 0 0 0; 
    position: relative; 
    top: 0px; 
    height: 37px; 
    width: 47px; 
    z-index: 10; 
    display: none; 
    background-color: transparent; 
    float: right; /* Different */ 
} 

頁面的CSS

.ArrowLeft 
{ 
    background-image: url(arrow_left.png); 
    border: 0 none transparent; 
    padding: 0 0 0 0; 
    position: absolute; 
    height: 24px; 
    width: 25px; 
    z-index: 10; 
    display: none; 
} 

.ArrowRight 
{ 
    background-image: url(arrow_right.png); 
    border: 0 none transparent; 
    padding: 0 0 0 0; 
    position: absolute; 
    left: 258px; 
    height: 24px; 
    width: 25px; 
    z-index: 10; 
    display: none; 
} 

    .Close 
    { 
     position: relative; 
     top: -1px; 
     left: 105px; 
    } 

注意的微小差異(margin: autofloat: left .. ECT)我想有這些差異不會發生在我的頁面的CSS中。我知道float: none將刪除floats但我如何刪除display,topmargin屬性是不同的?我只是改變類名,但所有的頁面使用相同的.js文件,所以重命名它們會很長/不需要。

對此提出建議?

有沒有辦法只關閉主CSS或禁用這些類?

編輯這是我在說什麼(箭頭):

enter image description here

回答

2

我不喜歡這樣寫道:

主頭部分:

<head> 
    <!-- other head stuff --> 

    <link href="css/master.css" rel="stylesheet" type="text/css" /> 
    <asp:ContentPlaceHolder ID="CPH_Css" runat="server" /> 
</head> 

ContentPage :

<asp:Content ID="Content1" ContentPlaceHolderID="CPH_Css" runat="server"> 
    <link href="css/content.css" rel="stylesheet" type="text/css" /> 
</asp:Content> 

通過這種方式,您可以用內容頁面中所需的任何細節覆蓋master.css。

+0

這就是我如何去做。我的主人已經被其他CSS所覆蓋,但是'display'' top'和'float'不在頁面的CSS中,所以沒有值可以覆蓋它們 – 2011-05-19 20:10:13

+0

那麼爲什麼不把它們放到頁面的CSS,並用你想要在頁面中的值覆蓋它們? – 2011-05-19 20:18:01

+0

這就是我正在做的。問題是我不知道如何覆蓋'margin'。我在一個編輯的螢火蟲圖像中顯示它。我認爲我沒有解釋我的問題 – 2011-05-19 20:19:36