最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Creating a Floating Widget that moves as the page scrolls - Stack Overflow

programmeradmin3浏览0评论

All, I'm using Wordpress widgets but I'd like to create a widget that floats down with the page as your scroll. Has anyone ever done anything like this? If so, can you give any remendations on how to achieve such a widget? Is it done merely by Javascript/CSS?

Thanks!

All, I'm using Wordpress widgets but I'd like to create a widget that floats down with the page as your scroll. Has anyone ever done anything like this? If so, can you give any remendations on how to achieve such a widget? Is it done merely by Javascript/CSS?

Thanks!

Share Improve this question asked Feb 27, 2012 at 19:18 user1048676user1048676 10.1k26 gold badges86 silver badges120 bronze badges 1
  • Read about position:fixed davidwalsh.name/css-fixed-position – Cheery Commented Feb 27, 2012 at 19:20
Add a ment  | 

4 Answers 4

Reset to default 4

The easiest way - to install this new WordPress plugin - Q2W3 Fixed Widget

It was specifically designed for this purpose!

Screenshots

All you need to do is set the position of the element in question to fixed via CSS, i.e.

.myFloatingWidget {position:fixed; left:0px; top:50%}

You need to give the widget a style of position:fixed;. Example at W3Schools.

slashnick's and maxedison's solutions will work.

If you'd like to have a dynamic scrolling box that doesn't always stay on the screen or minds the header, footer or any other div of your site, you might want to check out DropTheBit's sticky float jQuery plugin: http://dropthebit./74/sticky-floating-box/

发布评论

评论列表(0)

  1. 暂无评论