2016-11-08 37 views
0

我的div放置在彼此的上方/後面。div出現在彼此後面

td { 
 
    width: 14.28%; 
 
    height: 16.6%; 
 
    position: relative; 
 
    } 
 

 
.details { 
 
    position: absolute; 
 
    display: none; 
 
    background-color: gray; 
 
    overflow: visible; 
 
    border: 2px solid black; 
 
    } 
 

 
div:hover > .details {display: block;}
<table> 
 
<tr> 
 
<td *ngFor="let cell of ukeEn()"> 
 
       {{cell.text}} 
 
       <div class="outer" *ngIf="datoerContains(cell) != null"> 
 
        <div class="circle" *ngFor="let circle of datoerContains(cell)"></div> 
 
        <div class="details" *ngFor="let circle of datoerContains(cell)"> 
 
        {{circle.skole}} <br> 
 
        {{circle.kommentar}} <br> 
 
        SFO: {{circle.sfodag}} 
 
        </div> 
 

 
       </div> 
 
      </td> 
 
</tr> 
 
</table>

的問題是與details類。使用*ngFor,這裏創建了幾個div - 但您只能看到其中一個出現,因爲其他人隱藏在後面。

任何想法?我要測試兩種方法;彼此相鄰,並且在彼此之下。 我想避免在.details上刪除absolute,因爲它用於其他目的。

+0

那麼爲什麼確切的說.details絕對定位? –

+0

如果要保持絕對定位,您需要在'.details'上設置定位('left','top'等)。 –

+0

試過'display:inline-block;'? – weinde

回答

1

設法找到一個解決方案。 我從td.details中刪除了position,並且爲.outer添加了position: absolute。然後他們完全置於彼此之下。 爲了讓它們彼此相鄰,我只是加float: leftdetails

td { 
    width: 14.28%; 
    height: 16.6%; 
    } 

.outer { 
    position: absolute 
} 

.details { 
    display: none; 
    background-color: gray; 
    overflow: visible; 
    border: 2px solid black; 
    float: left; 
    } 
+0

不錯!好的工作m8:D – weinde

0

通過自己身邊只打了刪除工作對我罰款CSS .details display: none; ...

+0

不能做那個伴侶,它應該隱藏,直到你懸停。 – MariusJ

+0

好吧,你應該說,在xD np隊友 – weinde

+0

之前,你是否嘗試過將鼠標懸停在'​​'標籤上? 像這樣'td:hover {display:inline;}'你也可以嘗試添加'!important'來使風格變得舒服... – weinde