Bootstrap Affix “Back to Top” Link

前端 未结 2 1273
我寻月下人不归
我寻月下人不归 2021-01-31 12:01

Alright, I\'m having trouble understanding the Bootstrap Affix component. My goal is to have a \"Back to Top\" link appear at the bottom left of the screen (in the margin) if/wh

2条回答
  •  渐次进展
    2021-01-31 12:28

    Now that I understand the Affix component better, I have come up with the solution. After specifying a top offset and adjusting the CSS, it's working nicely. The link will scroll into view and then "pin" to the bottom. For pages which do not have a scroll bar, the link is never enabled. I've updated the JS Fiddle (here) with a working example. Key pieces are:

    HTML:

    
    
    

    JS:

    
    

    CSS:

    
    

    Note: I was not able to use the affix bottom offset (example) to hide the link for short pages due to a bug with affix container height calculation (Bootstrap Issue # 4647). I'm sure there is a workaround and would welcome the solution to this method.

提交回复
热议问题