2015-06-09 61 views
0

我是聚合物的新成員,我正在嘗試一點。我怎樣才能將我的組件設置爲全高? 這就是我所擁有的,由於某些原因,我無法使其工作。它只有他的內容的高度:如何將聚合物組分的高度設置爲100%

<link rel="import" href="/bower_components/polymer/polymer.html"> 

<dom-module id="reactive-navbar"> 
    <style> 
    div { 
     display: block; 
     width: 20%; 
     height: 100%; 
     background-color: #2c3e50; 
    } 
    </style> 
    <template> 
     <div> 
      <content></content> 
     </div> 
    </template> 
</dom-module> 

<script> 
Polymer({ 
    is: "reactive-navbar", 
}); 
</script> 
+0

您是否嘗試將樣式應用於div或您的聚合物元素?如果聚合物元素,你可以在你的樣式表中更改div:host https://www.polymer-project.org/1.0/docs/devguide/styling.html – blissfulyoshi

+0

我將div更改爲:host並更改了主體標籤在我的主要css文件有高度等於100vh,它似乎是工作得很好。 謝謝 – BCasaleiro

回答

1

如果你想通過你的風格,而不是你的div影響您的聚合物元件,可以改變該分區在你的風格標籤:主機,使您的風格影響主機https://www.polymer-project.org/1.0/docs/devguide/styling.html

更新代碼:

<link rel="import" href="/bower_components/polymer/polymer.html"> 

<dom-module id="reactive-navbar"> 
    <style> 
    :host { 
     display: block; 
     width: 20%; 
     height: 100%; 
     background-color: #2c3e50; 
    } 
    </style> 
    <template> 
     <content></content> 
    </template> 
</dom-module> 

<script> 
Polymer({ 
    is: "reactive-navbar", 
}); 
</script> 
0

在您的index.html文件,HTML標籤設置樣式:

html { 
    height: 100%; 
} 
相關問題