2017-04-18 1 views
0

私のリストを高さにすることはできません。私のコードはネストされたコンポーネントではもっと複雑です。しかし、私はまだこのコードを使用してこれを複製することができます。ここには塊がある。 http://plnkr.co/edit/R0QgLz8cjyRHYOLf4uJW角型コンポーネントの高さを設定する

Styles.cssを

html, body { 
    min-height: 100%; 
    height: auto; 
    margin: 0; 
} 

app.component.css

.container { 
height: 100%; 
background: black; 
color: white; 

list.component.css

.row { 
    display: flex; 
    flex-direction: row; 
} 
.list { 
    width: 33%; 
    height: 100%; 
    flex-direction: column; 
    display: flex; 
    border-right: groove white 1px; 
    border-top: groove white 1px; 
} 
.item { 
    width: auto; 
    height: 100%; 
    flex-direction: column; 
    display: flex; 
} 

list.component.html

<div class="contents"> 
    <button (click)="updateDocuments()">Update Document</button> 
    <div class="row"> 
    <div class="list"> 
     <div *ngFor="let document of documents; let i = index;"> 
     {{i + 1}}. {{document}} 
     </div> 
    </div> 
    <div class="item"> 
     this is an item 
    </div> 
    </div> 
</div> 

答えて

1

を書いてみますオーバーフロー-y:scroll css属性をリストクラスとアイテムクラスに追加しました。list.component.html

http://plnkr.co/edit/R0QgLz8cjyRHYOLf4uJW

Styles.cssを

html, body { 
    min-height: 100vh; 
    height: auto; 
    margin: 0; 
} 

app.component.css

.container { 
height: 100vh; 
background: black; 
color: white; 

list.component.css

.row { 
    display: flex; 
    flex-direction: row; 
} 
.list { 
    width: 33%; 
    height: 100vh; 
    flex-direction: column; 
    display: flex; 
    border-right: groove white 1px; 
    border-top: groove white 1px; 
    overflow-y: scroll; 
} 
.item { 
    width: auto; 
    height: 100vh; 
    flex-direction: column; 
    display: flex; 
    overflow-y: scroll; 
} 
<div class="contents"> 
    <button (click)="updateDocuments()">Update Document</button> 
    <div class="row"> 
    <div class="list"> 
     <div *ngFor="let document of documents; let i = index;"> 
     {{i + 1}}. {{document}} 
     </div> 
    </div> 
    <div class="item"> 
     this is an item 
    </div> 
    </div> 
</div> 
0

使用position: fixedそれが許容できるかどう:

.container { 
    position:fixed; 
    background: black; 
    color: white; 
    height: 100%; 
} 
+0

これはうまくいきたいです。リストが視認可能な高さよりも長い場合はスクロールできません。 – mkteagle

+0

あなたはちょうどそれをオーバーフロー? – unitario

+0

ここをクリックしてください:http://plnkr.co/edit/54mG5kYrowh0ixAM6CUb?p=preview – unitario

0

試して、あなたのstyle.cssで

html, body { 
height: 100%; 
margin: 0; 
} 
+0

これは高さを視認可能な高さにするために働きます。しかし、流動的で常に同じ高さではないダイナミックリストがある場合、これは機能しません。特にリストに枠線を追加している場合は特にそうです。 – mkteagle

2

が、私は、これは高さに切り替えることで動作するようになったこのCSSに

.container{ 
    min-height:100vh; 
} 
+1

'100vh'の意味を説明してみてください。この問題は問題を解決するかもしれませんが、何が起こっているのか、そしてなぜそれが説明されていません。 – Adam

+1

私は100vhの意味を理解しています。しかし、もし私が100vhを加えると、これは目に見える高さにしかならない。何かがそれを超えてプッシュされる場合はありません。 – mkteagle

関連する問題