原生js实现拖拽排序可添加列表效果代码

代码语言:html

所属分类:拖放

代码描述:原生js实现拖拽排序可添加列表效果代码

代码标签: 原生 js 拖拽 排序 添加 列表

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'>
  
<style>
@import url("https://fonts.googleapis.com/css?family=Raleway:300,800");
body {
  background-color: #0072ff;
}
body h1 {
  text-align: center;
  font-family: "Raleway", sans-serif;
  color: white;
  font-size: 50px;
  font-weight: normal;
}
body .adder {
  position: relative;
  width: 250px;
  margin: 0px auto;
  display: block;
}
body .adder ::-webkit-input-placeholder {
  color: #cecece;
}
body .adder .input {
  outline: none;
  border: 1px solid white;
  background-color: #0072ff;
  color: white;
  height: 50px;
  width: 250px;
  padding-left: 10px;
  font-family: "Raleway", sans-serif;
  font-weight: 800;
  font-size: 16px;
  margin-left: -5px;
}
body .adder span {
  position: absolute;
  right: 0;
  top: 0;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.8;
  cursor: pointer;
  transition: all 200ms;
  color: white;
  will-change: transform;
}
body .adder span:hover {
  transform: rotate(180deg);
}
body ul {
  padding: 0px;
}
body ul .draggable {
  will-change: transform;
  font-family: "Raleway", sans-serif;
  font-weight: 800;
  height: 50px;
  list-style-type: none;
  margin: 10px;
  background-color: white;
  color: #0072ff;
  width: 250px;
  line-height: 3.2;
  padding-left: 10px;
  cursor: move;
  transition: all 200ms;
  user-select: none;
  margin: 10px auto;
  position: relative;
}
body ul .draggable:after {
  content: "drag me";
  right: 7px;
  font-size: 10px;
  position: absolute;
  cursor: pointer;
  line-height: 5;
  transition: all 200ms;
  transition-timing-function: cubic-bezier(0.48, 0.72, 0.62, 1.5);
  transform: translateX(120%);
  opacity: 0;
}
body ul .draggable:hover:after {
  opacity: 1;
  transform: translate(0);
}

.over {
  transform: scale(1.1, 1.1);
}
</style>


  
</head>

  <body>
  <h1>DRAG AND DROP HTML5</h1>
  <div class="adder">
    <input type="text" class="input" placeholder="Add items in your list"/>
    <span class="add">+</span>
  </div>
  <ul>
    <li class="draggable" draggable="true">JavaScript</li>
    <li class="draggable" draggable="true">SCSS</li&.........完整代码请登录后点击上方下载按钮下载查看

网友评论0