Your second example can be fixed using:
#TryToPutDataSpyHere{ display:inline; }
But for some reason it doesn't work on a demo
I was able to reproduce your problem from the document: http://jsfiddle.net/baptme/KbphR/
But it only works if I had the following css code (used in the document):
.scrollspy-example { height: 200px; overflow: auto; position: relative; }
http://jsfiddle.net/baptme/KbphR/1/
It seems that height: 200px;
and overflow: auto;
both are necessary
In your case, it cannot be because of your .box{height: 500px;}
source share