html 裡有設定
也就是說上面有「一小塊的按鈕」(各位前輩應該很常見)
使用 a herf="#id" 錨點,來作移頁面的動作,但是 點擊連結 錨點會帶頁面到「最上面」,也就是說會有一部份被「header 」的部份蓋掉
我要如何 在跳錨點往下移一些呢?
跟這個差不多
http://segmentfault.com/q/1010000000124208
不過,我的 div id 是用產生的,當然我也試過一些 js
$(function(){ if(location.hash){ var target = $(location.hash); if(target.length==1){ var top = target.offset().top-100; if(top > 0){ $('html,body').animate({scrollTop:top}, 1000); } } } });
求大大解
1201 修改 hmtl如下
天下系統我最爛
回複內容:
html 裡有設定
也就是說上面有「一小塊的按鈕」(各位前輩應該很常見)
使用 a herf="#id" 錨點,來作移頁面的動作,但是 點擊連結 錨點會帶頁面到「最上面」,也就是說會有一部份被「header 」的部份蓋掉
我要如何 在跳錨點往下移一些呢?
跟這個差不多
http://segmentfault.com/q/1010000000124208
不過,我的 div id 是用產生的,當然我也試過一些 js
$(function(){ if(location.hash){ var target = $(location.hash); if(target.length==1){ var top = target.offset().top-100; if(top > 0){ $('html,body').animate({scrollTop:top}, 1000); } } } });
求大大解
1201 修改 hmtl如下
天下系統我最爛
想要位移到下面,應該只能用js了吧。
看了一樓那個朋友的方法,把他的span標籤的樣式改了一下,
.placeholder{display:block; width:100px; height:50px; margin-top:-50px; }
無 js 的實現。
歡迎採納。
使用position:absolute;脫離文檔流的方法改變錨點的位置,同時不影響展現。
http://jsbin.com/teqisuve/5/
PS. 採納樓下的更新
不跳轉到你想要的元素,在它上面設定一個空元素,跳到那