原生js+css实现图片拖动拼凑滑块验证代码

代码语言:html

所属分类:验证

代码描述:原生js+css实现图片拖动拼凑滑块验证代码

代码标签: 原生 js css 图片 拖动 拼凑 滑块 验证 代码

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

 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
    /* 整体容器的样式 */

.container {
    width: 280px;
    height: 400px;
    margin: 100px auto;
}

/* 上方的图片不好看切换一张的样式 */

.container .changeImg {
    text-align: center;
    position: relative;
    font-size: 16px;
    color: rgb(126, 57, 218);
    font-weight: bolder;
    cursor: pointer;
    user-select: none;
}

/* 前面的图标 */

.changeImg::before {
    content: '';
    display: block;
    position: absolute;
    left: 10%;
    top: calc(50% - 13px);
    width: 26px;
    height: 26px;
    background: url('//repo.bfw.wiki/bfwrepo/icon/680ecbd429c62.png') no-repeat;
    background-size: cover;
    background-position: center;
}

/* img 容器整体样式,包含标题 + 图片 + 滑条 */

.imgContainer {
    height: 320px;
    box-sizing: border-box;
    padding: 15px;
    border: 1px solid #adadad;
    box-shadow: 0px 0px 2px #adadad;
    /* 设置盒子阴影 */
    border-radius: 15px;
    /* 设置圆角 */
}

/* 上方标题 */

.imgContainer h3 {
    text-align: center;
    margin: 0;
    margin-bottom: 10px;
}

/* 中间的图片 */

.imgContainer .imgBox {
    width: 100%;
    height: 200px;
    background-repeat: no-repeat;
    position: relative;
}

/* 可以拖动的图片 */

.imgBox .imgBlock {
    width: 50px;
    height: 50px;
    position: absolute.........完整代码请登录后点击上方下载按钮下载查看

网友评论0