導航:首頁 > 編程語言 > 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

友情鏈接