admin管理员组文章数量:1302360
I try to create a floating menu like Aloha editor but it not working properly. Any one can help me with basic example for floating menu in jquery.
I am not looking for menu floating I need similar toolbar floating in Aloha editor
$(document).ready(function() {
var fBox = $('#box');
fBox.draggable();
$(".columns").click(function(e){
var mouseXPos = e.pageX;
var mouseYPos = e.pageY;
console.log("mouseXPos:" + mouseXPos + "cleft:" +mouseYPos);
fBox.animate({top:mouseYPos},1000);
fBox.animate({left:mouseXPos},1000);
});
});
CSS
<style>
#page{width:600px;margin:0 auto;}
#page .columns{float:left;width:250px;}
#box{ background-color: #FFFFFF;
border: 1px solid #CCCCCC;
left: 749px;
opacity: 0.9;
padding: 0 10px;
position: absolute;
top: 35px;
width: 216px;}
</style>
HTML
<div id="page">
<div class="columns">
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</div>
<div class="columns">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</div>
<div id="box">
<h2>hello world</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</div>
</div>
example floating toolbar /
I try to create a floating menu like Aloha editor but it not working properly. Any one can help me with basic example for floating menu in jquery.
I am not looking for menu floating I need similar toolbar floating in Aloha editor
$(document).ready(function() {
var fBox = $('#box');
fBox.draggable();
$(".columns").click(function(e){
var mouseXPos = e.pageX;
var mouseYPos = e.pageY;
console.log("mouseXPos:" + mouseXPos + "cleft:" +mouseYPos);
fBox.animate({top:mouseYPos},1000);
fBox.animate({left:mouseXPos},1000);
});
});
CSS
<style>
#page{width:600px;margin:0 auto;}
#page .columns{float:left;width:250px;}
#box{ background-color: #FFFFFF;
border: 1px solid #CCCCCC;
left: 749px;
opacity: 0.9;
padding: 0 10px;
position: absolute;
top: 35px;
width: 216px;}
</style>
HTML
<div id="page">
<div class="columns">
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</div>
<div class="columns">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</div>
<div id="box">
<h2>hello world</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</div>
</div>
example floating toolbar http://elankeeran./manish/prototype/alohaEditor/
Share edited May 21, 2011 at 9:41 Elankeeran asked May 21, 2011 at 7:57 ElankeeranElankeeran 6,1849 gold badges42 silver badges57 bronze badges 04 Answers
Reset to default 3There is a tutorial here:
Creating a Floating HTML Menu Using jQuery and CSS
I wanted to do the same and I found a great tutorial here!
You can just use CSS, and give the menu a style of position:fixed
Just be aware this won't work on Internet Explorer 6. For internet explorer you can then use jQuery to reposition the item. Use a conditional tag to include a stylesheet that sets your menu to position:absolute and then use something like the snipped below to move your div, when the window is scrolled:
$(window).scroll(function() {
$('#myElement').css('top', $(this).scrollTop() + "px");
});
Be aware that the scroll listener fires a lot, so you may want to throttle it to negate any performance issues. For more on that see John Resigs blog post here.
You might want to see Toolbar.js. It creates a tooltip like toolbar in which you can add various control. It's really nice looking and very customizable.
Toolbar.js - A jQuery Plugin To Create Responsive Tooltip Style Toolbars
本文标签: javascriptFloating menu toolbar in jqueryStack Overflow
版权声明:本文标题:javascript - Floating menu toolbar in jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741666833a2391360.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论