2016-07-28 52 views
0

我有一個關於帶有angularJs指令的樣式的問題。我已經爲我的項目中的progressbar導入了一個bootstrap指令。我在我創建的div類中使用它。不適用的角度指令

<div class="diagnostics-widget-modal"> 
    <div class="modal-header"> 
     <h3>SOME CONTENT</h3> 
    </div> 
    <div class="modal-body"> 
     <div class=left-workflow-area> 
      <uib-progressbar value="55"></uib-progressbar> 
     </div> 
    </div> 
</div> 

當我運行我的頁面時,指令html被正確渲染,並且那段代碼變成了以下內容。

<div class="modal-body"> 
    <div class="left-workflow-area"> 
     <div class="progressbar ng-isolate-scope" value="55"> 
       <div class="progress"> 
        <div class="progress-bar" ng-class="type &amp;&amp; 'progress-bar-' + type" role="progressbar" aria-valuenow="55" aria-valuemin="0" aria-valuemax="100" ng-style="{width: (percent < 100 ? percent: 100) + '%'}" aria-valuetext="%" aria-labelledby="" ng-transclude="" style="width: 100%;"> </div> 
       </div> 
     </div> 
    </div> 
</div> 

我想要的是風格的「進步」和「進度欄」類。我有一個定義左工作流區域的scss。

.diagnostics-widget-modal { 
    height: 100%; 
    width: 100%; 

    .modal-header { 
     height: 71px; 
     padding: 0 12px 0px 36px; 
     display: flex; 
     flex-direction: row; 
     align-items: center; 
     justify-content: space-between; 

     .modal-close { 
      width: 72px; 
      height: 72px; 
      display: flex; 
      align-items: center; 
      justify-content: center; 
     } 
    } 

    .modal-body { 
    display: flex; 
    flex-direction: row; 
    justify-content: space-between; 
    height: 90%; 

    .left-workflow-area { 
     display: flex; 
     width: 70%; 
     height: 100%; 
    } 

    .right-workflow-area { 
     display: flex; 
     width: 30%; 
     height: 100%; 
    } 
} 

我有一個沒有被應用的指令的樣式文件。

.progress { 
    height: 20px; 
    margin-bottom: 20px; 
    overflow: hidden; 
    background-color: #f5f5f5 
    border-radius: 4px; 
    box-shadow: inset 0 1px 2px rgba (0,0,0,.1); 
} 

如果我在「left-workflow-area」內聲明該類正在正確應用。但我想保持這種風格appart,因爲這是一個指令,將在我的應用程序的不同部分使用。我怎樣才能做到這一點?

回答

0

最後我解決了它。這是一個愚蠢的錯誤。我有一個大文件,我將所有樣式導入到項目中,並且完全忘記了將新組件包含在其中。

styles.scss

@import 'molecules/header'; 
@import '../components/dropdown/dropdown'; 
@import '../components/progressbar/progressbar'; 
@import '../components/keyboard/keyboard'; 
1

它在.progress位於.left-workflow-area時有效,因爲它生成爲.left-workflow-area .progress,它的引數比引導CSS提供的默認 .progress高。

如果.progress在外面時它不起作用,它看起來像默認.progress覆蓋它。它可能是由引導程序的CSS包含在你自己的HTML頁面或在你的編譯過程中引起的。當css規則具有相同的分數時,將應用瀏覽器上次讀取的內容。

因此,供應商的風格應該解決您的問題。

另一個注意事項:在.progress中,背景顏色的規則中缺少一個分號。

+0

您好,感謝您的答覆。我沒有包含在我的項目中的CSS樣式,這就是爲什麼我要寫它們。所以我的問題是,我根本沒有任何風格 – acostela

+0

你必須有css,否則根本沒有規則可以應用,''.left-workflow-area''內部或外部的''.progress''位置無關緊要。而且,正如[angular bootstrap](https://angular-ui.github.io/bootstrap/#/getting_started)中提到的那樣,bootstrap css是必需的 – jibe