1. [代码]index.html
<div class="albums">
<div class="album" id="drop_1" droppable="true"><h2>Album 1</h2></div>
<div class="album" id="drop_2" droppable="true"><h2>Album 1</h2></div>
<div class="album" id="drop_3" droppable="true"><h2>Album 3</h2></div>
</div>
<div ></div>
<div class="gallery">
<a id="1" draggable="true"><img src="images/1.jpg"></a>
<a id="2" draggable="true"><img src="images/2.jpg"></a>
<a id="3" draggable="true"><img src="images/3.jpg"></a>
<a id="4" draggable="true"><img src="images/4.jpg"></a>
<a id="5" draggable="true"><img src="images/5.jpg"></a>
<a id="6" draggable="true"><img src="images/6.jpg"></a>
<a id="7" draggable="true"><img src="images/7.jpg"></a>
<a id="8" draggable="true"><img src="images/8.jpg"></a>
<a id="9" draggable="true"><img src="images/9.jpg"></a>
<a id="10" draggable="true"><img src="images/10.jpg"></a>
<a id="11" draggable="true"><img src="images/11.jpg"></a>
<a id="12" draggable="true"><img src="images/12.jpg"></a>
</div>
<script src="js/main.js"></script>
2. [代码]css/main.css
/* Photo Gallery styles */
.gallery {
margin: 50px auto 0;
width: 840px;
}
.gallery a {
display: inline-block;
height: 135px;
margin: 10px;
opacity: 1;
position: relative;
width: 180px;
-khtml-user-drag: element;
/* CSS3 Prevent selections */
-moz-user-select: none;
-webkit-user-select: none;
-khtml-user-select: none;
user-select: none;
/* CSS3 transition rules */
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.gallery a img {
border: 8px solid #fff;
border-bottom: 20px solid #fff;
cursor: pointer;
display: block;
height: 100%;
left: 0px;
position: absolute;
top: 0px;
width: 100%;
z-index: 1;
/* CSS3 Box sizing property */
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
/* CSS3 transition rules */
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
/* CSS3 Box Shadow */
-moz-box-shadow: 2px 2px 4px #444;
-webkit-box-shadow: 2px 2px 4px #444;
-o-box-shadow: 2px 2px 4px #444;
box-shadow: 2px 2px 4px #444;
}
/* Custom CSS3 rotate transformation */
.gallery a:nth-child(1) img {
-moz-transform: rotate(-25deg);
-webkit-transform: rotate(-25deg);
transform: rotate(-25deg);
}
.gallery a:nth-child(2) img {
-moz-transform: rotate(-20deg);
-webkit-transform: rotate(-20deg);
transform: rotate(-20deg);
}
.gallery a:nth-child(3) img {
-moz-transform: rotate(-15deg);
-webkit-transform: rotate(-15deg);
transform: rotate(-15deg);
}
.gallery a:nth-child(4) img {
-moz-transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
transform: rotate(-10deg);
}
.gallery a:nth-child(5) img {
-moz-transform: rotate(-5deg);
-webkit-transform: rotate(-5deg);
transform: rotate(-5deg);
}
.gallery a:nth-child(6) img {
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
.gallery a:nth-child(7) img {
-moz-transform: rotate(5deg);
-webkit-transform: rotate(5deg);
transform: rotate(5deg);
}
.gallery a:nth-child(8) img {
-moz-transform: rotate(10deg);
-webkit-transform: rotate(10deg);
transform: rotate(10deg);
}
.gallery a:nth-child(9) img {
-moz-transform: rotate(15deg);
-webkit-transform: rotate(15deg);
transform: rotate(15deg);
}
.gallery a:nth-child(10) img {
-moz-transform: rotate(20deg);
-webkit-transform: rotate(20deg);
transform: rotate(20deg);
}
.gallery a:nth-child(11) img {
-moz-transform: rotate(25deg);
-webkit-transform: rotate(25deg);
transform: rotate(25deg);
}
.gallery a:nth-child(12) img {
-moz-transform: rotate(30deg);
-webkit-transform: rotate(30deg);
transform: rotate(30deg);
}
.gallery a:hover img {
z-index: 5;
/* CSS3 transition rules */
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
/* CSS3 transform rules */
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
.gallery a.hidden {
height: 0;
margin: 0;
opacity: 0;
width: 0;
}
.albums {
margin: 40px auto 0;
overflow: hidden;
width: 840px;
}
.album {
border: 3px dashed #ccc;
float: left;
margin: 10px;
min-height: 100px;
padding: 10px;
width: 220px;
/* CSS3 transition rules */
-webkit-transition: all 1.0s ease;
-moz-transition: all 1.0s ease;
-o-transition: all 1.0s ease;
transition: all 1.0s ease;
}
.album a {
display: inline-block;
height: 56px;
margin: 15px;
opacity: 1;
position: relative;
width: 75px;
-khtml-user-drag: element;
-webkit-user-drag: element;
-khtml-user-select: none;
-webkit-user-select: none;
/* CSS3 Prevent selections */
-moz-user-select: none;
-webkit-user-select: none;
-khtml-user-select: none;
user-select: none;
/* CSS3 transition rules */
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}http://www.huiyi8.com/hunsha/chuangyi/?
.album a img {创意婚纱照片
border: 4px solid #fff;
border-bottom: 10px solid #fff;
cursor: pointer;
display: block;
height: 100%;
left: 0px;
position: absolute;
top: 0px;
width: 100%;
z-index: 1;
/* CSS3 Box sizing property */
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
/* CSS3 transition rules */
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
/* CSS3 Box Shadow */
-moz-box-shadow: 2px 2px 4px #444;
-webkit-box-shadow: 2px 2px 4px #444;
-o-box-shadow: 2px 2px 4px #444;
box-shadow: 2px 2px 4px #444;
}
4. [代码]js/main.js
// add event handler
var addEvent = (function () {
if (document.addEventListener) {
return function (el, type, fn) {
if (el && el.nodeName || el === window) {
el.addEventListener(type, fn, false);
} else if (el && el.length) {
for (var i = 0; i < el.length; i++) {
addEvent(el[i], type, fn);
}
}
};
} else {
return function (el, type, fn) {
if (el && el.nodeName || el === window) {
el.attachEvent(‘on‘ + type, function () { return fn.call(el, window.event); });
} else if (el && el.length) {
for (var i = 0; i < el.length; i++) {
addEvent(el[i], type, fn);
}
}
};
}
})();
// inner variables
var dragItems;
updateDataTransfer();
var dropAreas = document.querySelectorAll(‘[droppable=true]‘);
// preventDefault (stops the browser from redirecting off to the text)
function cancel(e) {
if (e.preventDefault) {
e.preventDefault();
}
return false;
}
// update event handlers
function updateDataTransfer() {
dragItems = document.querySelectorAll(‘[draggable=true]‘);
for (var i = 0; i < dragItems.length; i++) {
addEvent(dragItems[i], ‘dragstart‘, function (event) {
event.dataTransfer.setData(‘obj_id‘, this.id);
return false;
});
}
}
// dragover event handler
addEvent(dropAreas, ‘dragover‘, function (event) {
if (event.preventDefault) event.preventDefault();
// little customization
this.style.borderColor = "#000";
return false;
});
// dragleave event handler
addEvent(dropAreas, ‘dragleave‘, function (event) {
if (event.preventDefault) event.preventDefault();
// little customization
this.style.borderColor = "#ccc";
return false;
});
// dragenter event handler
addEvent(dropAreas, ‘dragenter‘, cancel);
// drop event handler
addEvent(dropAreas, ‘drop‘, function (event) {
if (event.preventDefault) event.preventDefault();
// get dropped object
var iObj = event.dataTransfer.getData(‘obj_id‘);
var oldObj = document.getElementById(iObj);
// get its image src
var oldSrc = oldObj.childNodes[0].src;
oldObj.className += ‘hidden‘;
var oldThis = this;
setTimeout(function() {
oldObj.parentNode.removeChild(oldObj); // remove object from DOM
// add similar object in another place
oldThis.innerHTML += ‘<a id="‘+iObj+‘" draggable="true"><img src="‘+oldSrc+‘" /></a>‘;
// and update event handlers
updateDataTransfer();
// little customization
oldThis.style.borderColor = "#ccc";
}, 500);
return false;
});
HTML5 拖放:在相册中对照片进行排序
时间: 2024-10-17 01:27:50
HTML5 拖放:在相册中对照片进行排序的相关文章
jsp实现仿QQ空间新建多个相册名称,向相册中添加照片
工具:Eclipse,Oracle,smartupload.jar:语言:jsp,Java:数据存储:Oracle. 实现功能介绍: 主要是新建相册,可以建多个相册,在相册中添加多张照片,删除照片,删除相册,当相册下有照片时先删除照片才能删除相册. 因为每个相册和照片要有所属人,所以顺带有登录功能. 声明:只是后端实现代码,前台无任何样式,代码测试可行,仅供参考. 代码: 数据库连接帮助类: public class JDBCHelper { public static final String
获取某一个相册中所有照片和照片的缩略图
- (void)loadAssets { // Initialise _assets = [NSMutableArray new]; _assetLibrary = [[ALAssetsLibrary alloc] init]; // Run in the background as it takes a while to get all assets from the library dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE
swift -从相册中选择照片并上传
选择本地图片并上传是应用开发中一个比较常见的功能. 原文出自:www.hangge.com 转载请保留原文链接:http://www.hangge.com/blog/cache/detail_1174.html 我们使用 UIImagePickerController 可以很方便的从系统"照片"中选择图片,但我们会发现选择完毕后,通过图片的 info[UIImagePickerControllerReferenceURL] 得到的是一个引用路径,格式如下: 1 assets-
关于解决 从相册中选择照片后无法剪切图片以及无法加载图片的问题
程序分析: 主要分两个部分 (1)先拍照,然后剪切,最后显示出来. (2)从相册中选择一张照片进行剪切然后显示出来 代码参照<第一行代码>,书中的代码运行时(2)出现了问题,无法剪切图片且无法加载图片 MainActivity.java代码如下: 1 package com.example.lynn.choosepictest; 2 3 import android.content.Intent; 4 import android.graphics.Bitmap; 5 import an
iOS 删除相册中照片--来自简书
来自:http://www.jianshu.com/p/ac18aa3f28c2 最近公司的app有一个新功能是在app中删除相册的照片 ,本来是一个比较简单地功能,在做的过程中却发现AssetsLibary 框架并没有提供删除相册的API,网络上查找的时候这方面的信息也很少,最终在stackoverflow上发现了一个巧妙的方法,使用[ALAsset setImageData:metadata:completionBlock:]来实现删除照片的功能,可是也有人说这个API虽然能删除照片,但是它
iOS之SQLite中的查询与排序 访问手机相册 向手机相册中存图
Day05 SQLite中的查询与排序 按查询结果排序:[[email protected][NSSortDescriptor sortDescriptorWithKey:@"age"ascending:yes]]; 设置查询条件: NSPredicate *pre=nil; 1.比较运算符 > < >= <= == != pre=[NSPridicate [email protected]“age>40”]; 2. 范围运算符 IN BETWEE
Swift - 从相册中选择视频(过滤掉照片,使用UIImagePickerController)
(本文代码已升级至Swift4) 有时我们需要从系统相册中选择视频录像,来进行编辑或者上传操作,这时使用 UIImagePickerController 就可以实现. 默认情况下,UIImagePickerController 打开系统"照片"后允许用户选择所有的媒体文件(不管是照片还是录像),我们可以通过 mediaTypes 属性设置.让其只显示视频录像. 1,样例说明 (1)下面样例点击"选择视频"按钮后,会自动打开相册选择视频. (2)由于设置了 media
android 从相册中选择图片并判断图片是否旋转
今天在做图片合成时,首先从相册中选择图片,然后判断该图片是否旋转了,今天就讲下图片是否旋转,直接上代码 /** * 读取照片exif信息中的旋转角度 * * @param path * 照片路径 * @return角度 获取从相册中选中图片的角度 */ public static int readPictureDegree(String path) { if (TextUtils.isEmpty(path)) { return 0; } int degree = 0; try { ExifInt
HTML5 拖放(Drag 和 Drop)详解与实例
简介 拖放是一种常见的特性,即抓取对象以后拖到另一个位置. 在 HTML5 中,拖放是标准的一部分,任何元素都能够拖放. 先点击一个小例子:在用户开始拖动 <p> 元素时执行 JavaScript <p draggable="true" ondragstart="myFunction(event)">拖动我!</p> 提示: 链接和图片默认是可拖动的,不需要 draggable 属性. 定义和用法 在拖放的过程中会触发以下事件: