2013-01-11 54 views
0

嘿,夥計們一個獨立的「一」的標籤,我有以下佈局:將在「TD」標籤的底部

<table> 
    <tr> 
    <td> 
     <div> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     </div> 
    </td> 
    <td> 
     <div> 
     I´m smaller than the other<br> 
     I´m smaller than the other 
     </div> 
     <a href="">I should be at the bottom of my parent td</a> 
    </td> 
    </tr> 
</table> 

http://jsfiddle.net/BqxuM/

現在我要放置在了一個標籤在td-tag底部的第二個td-tag! 我嘗試了許多不同的事情來完成這個,但沒有成功。

那麼有人有答案讓我這個工作? PS:如果沒有js/jquery「黑客」,我會非常好。

+0

你有某種形式的圖表?很難理解你需要什麼。 – Kyle

回答

2

如果這是您將使用比僅結構使用position: relative;<table>position: absolute;<a>

Demo

CSS相對

table { 
    border: solid 1px black; 
    position: relative; 
} 

td { 
    padding: 5px; 
    border: solid 1px black; 
} 

a { 
    position: absolute; 
    bottom: 0; 
} 
+0

位置:絕對僅適用於頁面無法滾動的情況。 – Vogel612

+0

@ Vogel612它的工作原理,你只需要把你的位置絕對div與位置相對格子 –

+0

正確的是,但沒有,你會殺死整個佈局;) – Vogel612

0

使用position:

td { 
    padding: 5px; 
    border: solid 1px black; 
    position: relative; 
} 

td a { 
    position: absolute; 
    bottom: 0px; 
} 
1

CSS

.my-bottom-link-parent { 
    position:relative; 
    /* padding-bottom: the height of the a element */ 
} 

.my-bottom-link-parent a { 
    position:absolute; 
    bottom:0; 
} 

HTML

<table> 
    <tr> 
    <td> 
     <div> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     I´m bigger than the other<br> 
     </div> 
    </td> 
    <td class="my-bottom-link-parent"> 
     <div> 
     I´m smaller than the other<br> 
     I´m smaller than the other 
     </div> 
     <a href="">I should be at the bottom of my parent td</a> 
    </td> 
    </tr> 
</table> 
1

是否必須是在同一個TD?

如何:

<table> 
    <tr> 
     <td> 
      <div>big<br /> div</div> 
     </td> 
     <td> 
      <div>small div</div> 
     </td> 
    </tr> 
    <tr> 
     <td> 
     </td> 
     <td> 
      <a href="#">link here</a> 
     </td> 
    </tr> 
</table> 
0

這是一個例子,你如何能做到這一點:

parrent:位置:親屬; 孩子:位置:絕對;顯示:塊;底部:0;

td { 
padding: 5px; 
border: solid 1px black; 
position:relative; 
} 

a{ 
display:block; 
bottom:0; 
position:absolute; 
}  

http://jsfiddle.net/BqxuM/4/