导航:首页 > 编程语言 > jquery右侧浮动代码

jquery右侧浮动代码

发布时间:2023-09-01 05:26:58

① jquery怎么实现从右到左滑出来的效果

引入jquery.js,复制以下代码,即可运行

1,<style type="text/css">

2,.slide {

3,position: relative;

4,height: 200;

5,lightyellow;

6,}

7 ,

8,.slide .inner {

9,position: absolute;

10,left: 0;

11,bottom: 0;

12,height: 100;

13,lightblue; ,

14,width: 100%

15,}

16,</style>

1、slidetoggle() 交替slidedown(),slideup()

Html代码

<div id="slidebottom" class="slide">

<button>

slide it

</button>

<div class="inner">

Slide from bottom

</div>

</div>

Js代码

$('#slidebottom button').click(function() {

$(this).next().slideToggle();

});

2、左侧横向交替滑动 Animate Left

Html代码

<div id="slidewidth" class="slide">

<button>

slide it

</button>

<div class="inner">

Slide from bottom

</div>

</div>

Js代码

$("#slidewidth button").click(function(){

$(this).next().animate({width: 'toggle'});

});

3、左侧横向交替滑动 Animate Left Margin (非隐藏)

Html代码

<div id="slideleft" class="slide" style="width: 50%;float: right">

<button>

slide it

</button>

<div class="inner">

Slide from bottom

</div>

</div>

Js代码

$("#slideleft button").click(function(){

var $lefty = $(this).next();

$lefty.animate({

left:parseInt($lefty.css('left'),10)==0 ? -$lefty.outerWidth() : 0

});

});

4、右侧横向滑动Slide to right

Html代码

<div id="slidemarginleft" class="slide" style="width: 60%;float: left">

<button>

slide it

</button>

<div class="inner">

Slide from bottom

</div>

</div>

Js代码

$("#slidemarginleft button").click(function(){

var $marginlefty = $(this).next();

$marginlefty.animate({

marginLeft:parseInt($marginlefty.css('marginLeft'),10)==0 ? $marginlefty.outerWidth() : 0

});

});

② 在网页中插入浮动窗口,js代码或css代码(易看易懂)

css :
如 div { position:fixed;left:20px;top:100px; }
这个div就浮动在屏幕上了,水平方向便宜20px,竖直方向偏移100px;

③ 浮动窗口的代码 (html/js)

第一种方法:
Html代码
<html>
<head>
<title>浮动窗口</title>
<link type="text/css" rel="stylesheet" href="css/overflow.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/overflow.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var b = $("#b");
var overFlow = $("#over");
b.click(function(){
overFlow.fadeIn();
$("#mask").css("background","#111");
$("#mask").css("opacity","0.8");
})
$("#close").click(function(){
overFlow.fadeOut();
$("#mask").css("background","#fff");
$("#mask").css("opacity","1");
});
drag($("#over"),$("#title"));
}) ;
</script>
</head>
<body>
<div id="over">
<div id="title"><span id="t">这只是一个演示标题</span><span id="close">[ x ]</span></div>
<div id="content">
When a container object, such as a div, has mouse capture, events originating on objects within that container are fired by the div, unless the bContainerCapture parameter of the setCapture method is set to false. Passing the value false causes the container to no longer capture all document events. Instead, objects within that container still fire events, and those events also bubble as expected.<br/>
---This is edited by Alp.
</div>
</div>
<div id="mask"> <a id="b" href="#">click</a></div>
</body>
</html>

Js代码
function drag(overFlow,title){
title.onmousedown = function(evt){
var doc = document;
var evt = evt || window.event;
var x = evt.offsetX?evt.offsetX:evt.layerX;
var y = evt.offsetY?evt.offsetY:evt.layerY;
if(overFlow.setCapture){
overFlow.setCapture();
}else if(window.captureEvents){
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}
doc.onmousemove = function(evt){
evt = evt || window.event;
var xPosition = evt.pageX || evt.clientX;
var yPosition = evt.pageY || evt.clientY;
var newX = xPosition - x;
var newY = yPosition - y;
overFlow.style.left = newX;
overFlow.style.top = newY;
};
doc.onmouseup = function(){
if(overFlow.releaseCapture){
overFlow.releaseCapture();
}else if(window.captureEvents){
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}
doc.onmousemove=null;
doc.onmouseup=null;
};
};
}

css代码
#over{
position: absolute;
left: 300px;
top: 200px;
border: 1px solid black;
display: none;
background: #cccccc;
cursor: default;
width: 300px;
z-index: 10;
opacity: 1;
}
#title{
border: 1px solid #1840C4;
background: #95B4DC;
padding: 2px;
font-size:12px;
cursor: default;
}
#close{
cursor: pointer;
margin-right: 1px;
overflow: hidden;
}
#content{
border: 1px solid #C2D560;
background: #EFF4D7;
}
#t{
margin-right:145px;
}
#mask{
z-index: 1;
background: #fff;
width: 1024px;
height: 800px;
}
#b{
position: absolute;
left: 200px;
top: 100px;
}
body{
padding: 0px;
margin: 0px;
}
#over{
background: transparent;
}

第二种方法:
消息框遮罩层:<iframe id="show_upload_iframe" frameborder=0 scrolling="no" style="display:none; position:absolute;"></iframe><div id="show_upload">nothing...</div>'

页面加载loading中:<div id="body_loading" onClick="loaded();"><img src="__PUBLIC__/images/body_load.gif"></div>

关闭浮动窗口:<a href="javascript:hideupload()">关闭窗口建议用小图片</a>

打开浮动窗口:<a href="javascript:showupload('admin.php')">打开浮动</a>
// 消息框loading
function loading(){
var o = $('#body_loading');
o.css("left",(($(document).width())/2-(parseInt(o.width())/2))+"px");
o.css("top",(($(document).height()+$(document).scrollTop())/2-(parseInt(o.height())/2))+"px");
o.fadeIn("fast");
}
// 消息框消失
function loaded(){
var o = $('#body_loading');
o.fadeOut("fast");
}
// 隐藏浮动窗口
function hideupload(){
$('#show_upload').hide();
$('#show_upload_iframe').hide();
}
// 弹出浮动窗口
function showupload(ajaxurl){
loading();
var o=$('#show_upload');
var f=$('#show_upload_iframe');
var top = 200;
$.ajax({
url: ajaxurl,
//cache: false,
success: function(res){
loaded();
o.html(res);
o.css("left",(($(document).width())/2-(parseInt(o.width())/2))+"px");
if($(document).scrollTop()>200){
top = ($(document).height()+$(document).scrollTop())/2-(parseInt(o.height())/2);
}
o.css("top",top+"px");
f.css({'width':o.width(),'height':o.height(),'left':o.css('left'),'top':o.css('top')});
f.show();
o.show();
}
});
}

④ 求网站jq右侧客服悬浮窗代码

<body>
<div style="height:10000px;"></div>
<div class="suspension">
<div class="suspension-box">
<a href="#" class="a a-service "><i class="i"></i></a>
<a href="javascript:;" class="a a-service-phone "><i class="i"></i></a>
<a href="javascript:;" class="a a-qrcode"><i class="i"></i></a>
<a href="#" class="a a-cart"><i class="i"></i></a>
<a href="javascript:;" class="a a-top"><i class="i"></i></a>
<div class="d d-service">
<i class="arrow"></i>
<div class="inner-box">
<div class="d-service-item clearfix">
<a href="#" class="clearfix"><span class="circle"><i class="i-qq"></i></span><h3>咨询在线客服</h3></a>
</div>
</div>
</div>
<div class="d d-service-phone">
<i class="arrow"></i>
<div class="inner-box">
<div class="d-service-item clearfix">
<span class="circle"><i class="i-tel"></i></span>
<div class="text">
<p>服务热线</p>
<p class="red number">4001-123-456</p>
</div>
</div>
<div class="d-service-intro clearfix">
<p><i></i>功能和特性</p>
<p><i></i>价格和优惠</p>
<p><i></i>获取内部资料</p>
</div>
</div>
</div>
<div class="d d-qrcode">
<i class="arrow"></i>
<div class="inner-box">
<div class="qrcode-img"><img src="images/side_ewm.jpg" alt=""></div>
<p>微信服务号</p>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
/* ----- 侧边悬浮 ---- */
$(document).on("mouseenter", ".suspension .a", function(){
var _this = $(this);
var s = $(".suspension");
var isService = _this.hasClass("a-service");
var isServicePhone = _this.hasClass("a-service-phone");
var isQrcode = _this.hasClass("a-qrcode");
if(isService){ s.find(".d-service").show().siblings(".d").hide();}
if(isServicePhone){ s.find(".d-service-phone").show().siblings(".d").hide();}
if(isQrcode){ s.find(".d-qrcode").show().siblings(".d").hide();}
});
$(document).on("mouseleave", ".suspension, .suspension .a-top", function(){
$(".suspension").find(".d").hide();
});
$(document).on("mouseenter", ".suspension .a-top", function(){
$(".suspension").find(".d").hide();
});
$(document).on("click", ".suspension .a-top", function(){
$("html,body").animate({scrollTop: 0});
});
$(window).scroll(function(){
var st = $(document).scrollTop();
var $top = $(".suspension .a-top");
if(st > 400){
$top.css({display: 'block'});
}else{
if ($top.is(":visible")) {
$top.hide();
}
}
});

});
</script>
</body>

⑤ 请帮我找一段特效代码,右侧浮动代码。效果是网页滚动后出现向上箭头,可以直接返回顶部。

你试一下这个。

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"
<title>测试</title>
<style>.float{margin:15px;background:#F8F8F8;border-radius:6px;border:solid1gray}
.b{color:007FFF}
</style>
<script>varRt
window.onscroll=function(){goTop.style.display="";clearTimeout(Rt);Rt=setTimeout("goTop.style.display='none'",3000)}</script>
<body><ahref=#Bottomname=Top>到底部↓</a><aclass=bonclick=window.location.reload()>刷新</a>
<divstyle="position:absolute;width:200px;height:2000px;left:820px;background:#eee">
<divstyle="position:fixed;width:200px;text-align:center;top:300px">
<divclass="float"><imgstyle="width:140px;height:160px;margin:8px"alt=二维码>手机菜谱</div>
<divclass="float"><imgstyle="width:140px;height:100px;margin:8px"alt=收藏>收藏</div>
<divclass="float"id=goToponclick=document.body.scrollTop=0;document.documentElement.scrollTop=0><imgstyle="width:140px;height:100px;margin:8px;border:solid1gray"alt=向上箭头>返回顶部</div></div>
</div>
<divstyle="width:800px;height:2000px;background:#F8F8F8">内容</div>
<ahref=#Topname=Bottom>回顶部↑</a></body>

⑥ jquery代码,点击图片中左侧或者右侧一个箭头图片,怎样实现图片切换

给图片设置点击事件onclcik,点击时获取图片在页面的位置,然后在图片的位置上显示浮动的箭头图片。这一系列事件稍微有点复杂,没有现成的代码。需要把事件和位置搞清楚。

阅读全文

与jquery右侧浮动代码相关的资料

热点内容
90版本升级不送 浏览:186
工具箱英文 浏览:382
南翔嘉定编程课哪里好 浏览:853
win10改变文件格式 浏览:475
linux中的物理地址和虚拟地址 浏览:493
有哪些app可以接游戏订单 浏览:472
苹果硬盘数据恢复要多少钱 浏览:394
js绑定下拉框数据库数据 浏览:448
cad文件怎么复制到另一个文件里边 浏览:858
dxp钻孔文件 浏览:631
iphone大悦城换机 浏览:538
找结婚对象上什么网站 浏览:974
学生信息管理系统程序设计报告 浏览:640
微信文件怎么删除怎么恢复 浏览:407
编程程序怎么复制 浏览:467
文件更改 浏览:327
冰点文件路径 浏览:730
软件一点开文件就关闭 浏览:88
网络如何把人捧红 浏览:961
软件传输文件 浏览:184

友情链接