I want to attach a sticky element(containing social media icons) to the right of my main wrap开发者_StackOverflow中文版per which has a width of 960px and not stuck to the right side of the screen.
Any simple CSS ways of doing this?
Thanks
div#wrapper {
position: relative;
}
div#socialmediaicons {
position: absolute;
top: 0;
right: 0;
}
<div id="wrapper">
<div id="socialmediaicons"> ... </div>
</div>
"Absolutely" positioned elements will be positioned with respect to the closest parent element that is itself positioned.
There is a good jQuery plugin for this very need:
http://plugins.jquery.com/project/stickyfloat
Tt gives you powers beyond mere CSS.
精彩评论