2013-05-30 28 views
0

我有一個高度> 1000的表格。它在第一個和最後一個TD上分別具有Prev和Next按鈕。我希望Prev和Next按鈕相對於屏幕位於中間。我不想使用JQuery。移動圖像以及TD或DIV中的滾動

 
TABLE - 
_________________________________________ 
|  |      |  | 
| TD1 |   TD2   | TD3 | 
|  |      |  | 
|  |      |  | 
|--------|---------------------|--------|----------------------------- 
|  |      |  |    _ 
|  |      |  |    | 
|  |      |  |    | 
|  |      |  |    | 
| ## |      | ## |  Screen view now 
|  |      |  |    | 
|  |      |  |    | 
|  |      |  |    | 
|  |      |  |    _ 
|--------|---------------------|--------|----------------------------- 
|  |      |  | 
|  |      |  | 
|  |      |  | 
|  |      |  | 
----------------------------------------- 

Legend : ## - Button 
+0

你可以給​​的寬度?然後應用保證金:0 auto;按鈕? – JDavies

+0

vertical-align:middle – claustrofob

+0

不,我希望圖像能夠在滾動時自我居中。 – Anirudh

回答

1

的按鈕元素設置樣式:

.button { 
    position: fixed; 
    top: 50%; 
} 

雖然按鈕不會完全在中間(加上高度的一半),應該OK

+0

正是我想要的。謝謝wachK! – Anirudh

0

嘗試使用CSS。給每個按鈕一個班,並調整他們的利潤率。例如:

HTML

<div class="btnNext"> button info goes here </div> 
<div class="btnPrev"> button info goes here </div> 

CSS

.btnNext 
{ 
    margin-left: auto; 
    margin-right: auto; 
    position: fixed; 
bottom: 0px; 
} 

.btnPrev 
{ 
    margin-left: auto; 
    margin-right: auto; 
    position: fixed; 
    bottom: 0px; 
} 
+0

不知道你是否遇到了我的問題,我希望按鈕在向下滾動或向上滾動時保持固定在屏幕上。 – Anirudh

+0

好吧,對不起。讓我再試一次:如果我明白你想要什麼。它就像這個頁面上的框:http://ryanfait.com/position-fixed-ie6/它保留在原地,而所有東西都在它周圍滾動。這應該可以解決你的問題。底部/頂部可用於相對於屏幕高度定位按鈕。我使用的0px將把按鈕放在底部。使用50%的值會使其完全居中 – 2013-05-30 15:19:52

+0

得到了答案傑森, http://stackoverflow.com/a/16839387/1458387 謝謝 – Anirudh