开发者

How do I attach a sticky element exactly to the side of my main wrapper

开发者 https://www.devze.com 2023-03-30 23:35 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消