2016-06-28 24 views
0

所以我有一個trtable之內。 onClick它附加一些html。我試圖使tr它附加轉換很好,所以我試圖設置高度爲0,然後onClick將其設置爲自動。無論子元素如何,強制div的高度爲0

但是,我的div沒有取高度0.我可以加height: 0;,但它仍然保持高度。

我的HTML:

<tr class="info_container"> 
    <td colspan="7">Pick a time 
     <button id="time_btn">Button</button> 
     <span class="tickets_left_cont"> 7 tickets left</span> 
    </td> 
</tr> 

CSS:

.info_container { 
    background: #fff; 
    color: #000; 
    z-index: 999; 
    left: 0; 
    width: 100%; 
    padding: 15px; 
    -webkit-transition: all 1s ease-in-out; 
    -moz-transition: all 1s ease-in-out; 
    -o-transition: all 1s ease-in-out; 
    transition: all 1s ease-in-out; 
    opacity: 0; 
    text-align: left; 
    font-family: BreeSerifLt; 
    border-bottom: 3px solid #000; 
} 

#time_btn { 
    outline: 0; 
    padding: 10px; 
    background: #9A0FC7; 
    border: 0; 
    color: #fff; 
    display: block; 
    margin-top: 10px; 
    font-weight: 300; 
    font-family: BreeSerifLt; 
} 

我在做什麼錯?爲什麼我不能讓info_container班級高度0因此它隱藏了div?

謝謝!

+0

的可能的複製[不管設置表格列寬恆定在其細胞中的文本的量的?](http://stackoverflow.com/questions/ 4457506/set-the-table-column-width-constant-the-the-amount-of-text-in-its-its-cell) –

回答

1

在表,heightwidth表現爲min-heightmin-width

+0

哦,謝謝你,我沒有意識到這一點。所以,當我想改變表格中元素的高度時,我需要使用'max-height'。 – PourMeSomeCode

+0

看這裏:http://stackoverflow.com/questions/5286747/how-to-force-a-td-to-be-a-certain-height-with-css –

相關問題