2017-01-30 109 views
0

我知道這個問題上有很多問題,但我不能得到解決方案。 我創建了一個名爲'color-shift'的CSS類,它通過色調將顏色轉換爲任何東西,我創建了它,以便標題徽標和文本可以在顏色中循環。但是現在我想添加一些黑色背景,使用CSS類改變顏色。問題是,背景是應用於div類的'包裝'。這個div包含整個頁面,所以一切都會改變顏色。我不知何故想從主容器中排除'color-shift'類,以便只有背景改變顏色。我該如何阻止從父級繼承CSS類的div?

任何幫助,將不勝感激。 (如果你需要知道的話,我正在使用Magento 1.9)。

下面是相關的HTML和CSS:

.wrapper { 
 
    min-width: 320px; 
 
    min-height: 100%; 
 
    margin: 0 auto; 
 
    background-image: url(/media/mountains-min.jpg); 
 
    background-size: cover; 
 
    background-attachment: fixed; 
 
} 
 

 
.color-shift { 
 
    -webkit-animation: hue 15s infinite linear; 
 
}
<div class="wrapper color-shift"> 
 
    <div class="page"> 
 
    </div> 
 
</div>

回答

0

你有兩種選擇。

1.您需要在CSS樣式表中覆蓋該類。

例如:

.color-shift { 
    -webkit-animation: hue 15s infinite linear; 
} 

.page { 
     -webkit-animation: none; 
     color:black; 
} 

下面添加它,所以它覆蓋前一個。

  1. 僅爲該類製作一個div。

例子:

<div class="wrapper"> 
    <div class="color-shift></div> 
    <div class="page"> 
    </div> 
</div> 
+0

謝謝!!!!!! –