2017-04-18 66 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

我这来切换到工作高度100vh,并在列表和项目类中添加overflow-y:scroll css属性。

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; 
} 

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> 
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