2017-07-18 40 views
1

我有一個非主頁,看起來像這樣
Login爲什麼沒有一些CSS屬性出現在我的母版頁中?

現在我有一個母版頁和內容佔位裏面我有一個div標籤,在我寫的具體內容上的按鈕頁時,標籤上的按鈕看起來像這樣

enter image description here
現在,他們具有相同的CSS屬性,但他們不會在母版頁一個顯示出來,這裏是div標籤的代碼和按鈕

.container-div 
{ 
    position:absolute; 
    padding-top:8%; 
    padding-left:10%; 
    padding-right:10%; 
    max-height:80%; 
    z-index:0; 
    font-family:Calibri; 

} 

#buttons { 
    position:absolute; 
    display: inline-block; 
    padding: 6px 12px; 
    margin-bottom: 0; 
    font-size: 14px; 
    font-weight: normal; 
    line-height: 1.428571429; 
    text-align: center; 
    white-space: nowrap; 
    border: 1px solid transparent; 
    border-radius: 4px; 
    cursor:pointer; 
    z-index:20; 
} 

#buttons:hover { 
    background-color:cadetblue; 
} 

,這是HTML代碼

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> 

<div id="placeHolderDiv" class="container-div" runat="server"> 

    <asp:Button id="buttons" runat="server" Text="Cancel" CssClass="buttons" OnClick="cancel"/> 


</div> 

+0

「這是html代碼」 - 不,它不是。這是ASP.NET代碼。 HTML是發送到瀏覽器的內容。查看瀏覽器*中的源代碼*。 – Quentin

回答

2

變化CSS類從#buttons到由於主頁下.buttons 生成的ID將是不完全按鈕,但會有ID製備型結束。你可以檢查來源。

.buttons { 
    position:absolute; 
    display: inline-block; 
    padding: 6px 12px; 
    margin-bottom: 0; 
    font-size: 14px; 
    font-weight: normal; 
    line-height: 1.428571429; 
    text-align: center; 
    white-space: nowrap; 
    border: 1px solid transparent; 
    border-radius: 4px; 
    cursor:pointer; 
    z-index:20; 
} 

.buttons:hover { 
    background-color:cadetblue; 
} 
+0

工作的Thankyou! –

-1

一些編譯器有與解析多個元素用相同的硬id時間,ID應唯一身份。

更改爲「類=按鈕」和CSS選擇到.buttons{};

相關問題