jQuery图片拖拽网格布局,图片拖拽插件。
发表日期: 2020-07-18 16:03:56 浏览次数:118
永康400电话怎么申请开通【永康400电话办理流程】永康400电话月租费多少钱、永康企业400电话服务热线一年大概多少钱、永康400电话收费标准报价单【企业4006电话4008电话如何办理开通】
永康,古称丽州,浙江省金华市代管县级市,位于浙江省中部的低山丘陵地区。市人民政府驻东城街道金城路15号。
相传,三国吴赤乌八年(公元245年)孙权之母因病到此进香,祈求“永保安康”,太夫人病愈,孙权大喜,遂赐名为“永康”,并单立为县。唐朝时曾擢升为州。1992年经国务院批准,撤县设市。辖10镇、4街道和1个经济开发区。
2017年6月,永康市被命名国家卫生城市。2018年11月,入选2018年工业百强县(市)、 中国城市全面小康指数前100名。 2018年12月,入选全国县域经济综合竞争力100强、 投资潜力100强、2019全国营商环境百强县。 第二批节水型社会建设达标县(区)。 2019年11月15日,获评国家森林城市。
jQuery图片拖拽网格布局,图片拖拽插件。
新建html。
在body标签中输入html。
<div class="item_container">
<div class="item_content" id="imageChange">
<ul>
<li>
<div class="item"> <img src="img/500x500-1.png" width="150" height="150">
<span onClick="removePicture(this)" class="rmPicture close">×</span> </div>
</li>
<li>
<div class="item"> <img src="img/500x500-2.png" width="150" height="150">
<span onClick="removePicture(this)" class="rmPicture close">×</span> </div>
</li>
<li>
<div class="item"> <img src="img/500x500-3.png" width="150" height="150">
<span onClick="removePicture(this)" class="rmPicture close">×</span> </div>
</li>
<li>
<div class="item"> <img src="img/500x500-4.png" width="150" height="150">
<span onClick="removePicture(this)" class="rmPicture close">×</span> </div>
</li>
<li>
<div class="item"> <img src="img/500x500-5.png" width="150" height="150">
<span onClick="removePicture(this)" class="rmPicture close">×</span> </div>
</li>
<li>
<div class="item"> <img src="img/500x500-6.png" width="150" height="150">
<span onClick="removePicture(this)" class="rmPicture close">×</span> </div>
</li>
<li>
<div class="item"> <img src="img/500x500-7.png" width="150" height="150">
<span onClick="removePicture(this)" class="rmPicture close">×</span> </div>
</li>
<li>
<div class="item"> <img src="img/500x500-8.png" width="150" height="150">
<span onClick="removePicture(this)" class="rmPicture close">×</span> </div>
</li>
<li>
<div class="item"> <img src="img/500x500-9.png" width="150" height="150">
<span onClick="removePicture(this)" class="rmPicture close">×</span> </div>
</li>
</ul>
</div>
</div>
书写css样式。
<style type="text/css">
.item_content ul{list-style:none;}
.item_content ul li{width:200px;height:160px;float:left;margin:10px }
.item_content{width:740px;height:auto;border:1px solid #ccc;float:left;}
.item_content .item{width:200px;height:120px;line-height:120px;text-align:center;cursor:pointer;background:#ccc;}
.item_content .item img{width:200px;height:120px;border-radius:6px;}
.close{display:block;width:20px;height:20px;top:0;right:0;z-index:9999;position:absolute;text-align:center;font-size:16px;cursor:pointer;color:aliceblue;}
</style>
书写jq特效。
<script>
$(function() {
function Pointer(x, y) {
this.x = x ;
this.y = y ;
}
function Position(left, top) {
this.left = left ;
this.top = top ;
}
$(".item_container .item").each(function(i) {
this.init = function() {
this.box = $(this).parent() ;
$(this).attr("index", i).css({
position : "absolute",
left : this.box.offset().left,
top : this.box.offset().top
}).appendTo(".item_container") ;
this.drag() ;
},
this.move = function(callback) {
$(this).stop(true).animate({
left : this.box.offset().left,
top : this.box.offset().top
}, 500, function() {
if(callback) {
callback.call(this) ;
}
}) ;
},
this.collisionCheck = function() {
var currentItem = this ;
var direction = null ;
$(this).siblings(".item").each(function() {
if(
currentItem.pointer.x > this.box.offset().left &&
currentItem.pointer.y > this.box.offset().top &&
(currentItem.pointer.x < this.box.offset().left + this.box.width()) &&
(currentItem.pointer.y < this.box.offset().top + this.box.height())
) {
if(currentItem.box.offset().top < this.box.offset().top) {
direction = "down" ;
} else if(currentItem.box.offset().top > this.box.offset().top) {
direction = "up" ;
} else {
direction = "normal" ;
}
this.swap(currentItem, direction) ;
}
}) ;
},
this.swap = function(currentItem, direction) {
if(this.moveing) return false ;
var directions = {
normal : function() {
var saveBox = this.box ;
this.box = currentItem.box ;
currentItem.box = saveBox ;
this.move() ;
$(this).attr("index", this.box.index()) ;
$(currentItem).attr("index", currentItem.box.index()) ;
},
down : function() {
var box = this.box ;
var node = this ;
var startIndex = currentItem.box.index() ;
var endIndex = node.box.index(); ;
for(var i = endIndex; i > startIndex ; i--) {
var prevNode = $(".item_container .item[index="+ (i - 1) +"]")[0] ;
node.box = prevNode.box ;
$(node).attr("index", node.box.index()) ;
node.move() ;
node = prevNode ;
}
currentItem.box = box ;
$(currentItem).attr("index", box.index()) ;
},
up : function() {
var box = this.box ;
var node = this ;
var startIndex = node.box.index() ;
var endIndex = currentItem.box.index(); ;
for(var i = startIndex; i < endIndex; i++) {
var nextNode = $(".item_container .item[index="+ (i + 1) +"]")[0] ;
node.box = nextNode.box ;
$(node).attr("index", node.box.index()) ;
node.move() ;
node = nextNode ;
}
currentItem.box = box ;
$(currentItem).attr("index", box.index()) ;
}
}
directions[direction].call(this) ;
},
this.drag = function() {
var oldPosition = new Position() ;
var oldPointer = new Pointer() ;
var isDrag = false ;
var currentItem = null ;
$(this).mousedown(function(e) {
e.preventDefault() ;
oldPosition.left = $(this).position().left ;
oldPosition.top = $(this).position().top ;
oldPointer.x = e.clientX ;
oldPointer.y = e.clientY ;
isDrag = true ;
currentItem = this ;
}) ;
$(document).mousemove(function(e) {
var currentPointer = new Pointer(e.clientX, e.clientY) ;
if(!isDrag) return false ;
$(currentItem).css({
"opacity" : "0.8",
"z-index" : 999
}) ;
var left = currentPointer.x - oldPointer.x + oldPosition.left ;
var top = currentPointer.y - oldPointer.y + oldPosition.top ;
$(currentItem).css({
left : left,
top : top
}) ;
currentItem.pointer = currentPointer ;
currentItem.collisionCheck() ;
}) ;
$(document).mouseup(function() {
if(!isDrag) return false ;
isDrag = false ;
currentItem.move(function() {
$(this).css({
"opacity" : "1",
"z-index" : 0
}) ;
}) ;
}) ;
}
this.init() ;
}) ;
}) ;
</script>
添加引用min.js。
<script src="js/jquery-1.8.3.min.js"></script>
网页整体代码架构。
查看效果。
暂停172天后,国内跨省游恢复开放。日前,文化和旅游部印发《关于推进旅游企业扩大复工复业有关事项的通知》,《通知》明确,跨省团队旅游可在有条件的情况下有序恢复,旅游景区接待游客量由不得超过最大承载量的30%调至50%。
为帮助国内酒店旅游业在安全前提下进一步加速复苏,7月17日,第九届中国饭店文化节开启。文化节期间,中国饭店协会将联合美团酒店开展为期一个月的全国首届“717
百城千店绿色消费节”活动,联动全国超100个城市的30多家酒店集团、1500多家酒店推出多项特惠活动,协力营造“放心吃、安心住、健康行”的绿色消费氛围。
永康400电话怎么申请开通【永康400电话办理流程】永康400电话月租费多少钱、永康企业400电话服务热线一年大概多少钱、永康400电话收费标准报价单【企业4006电话4008电话如何办理开通】