js面向对象实现标签添加删除切换更名效果

代码语言:html

所属分类:选项卡

代码描述:js面向对象实现标签添加删除切换更名效果,通过es6中的class来实现

代码标签: 实现 标签 添加 删除 切换 更名 效果

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

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>面向对象 Tab</title>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        ul li {
            list-style: none
        }

        main {
            width: 960px;
            height: 500px;
            border-radius: 10px;
            margin: 50px auto
        }

        main h4 {
            height: 100px;
            line-height: 100px;
            text-align: center
        }

        .tabsbox {
            width: 900px;
            margin: 0 auto;
            height: 400px;
            border: 1px solid #ffa07a;
            position: relative
        }

        nav ul {
            overflow: hidden
        }

        nav ul li {
            float: left;
            width: 100px;
            height: 50px;
            line-height: 50px;
            text-align: center;
            border-right: 1px solid #ccc;
            position: relative
        }

        nav ul li.liactive {
            border-bottom: 2px solid #fff;
            z-index: 9
        }

        #tab input {
            width: 80%;
            height: 60%
        }

        nav ul li span:last-child {
            position: absolute;
            user-select: none;
            font-size: 12px;
            top: -18px;
            right: 0;
            display: inline-block;
            height: 20px;
            cursor: pointer
        }

        .tabadd {
            position: absolute;
            top: 0;
            right: 0;
            cursor: pointer
        }

        .tabadd span {
            display: block;
            width: 20px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            border: 1px solid #ccc;
            float: right;
            margin: 10px;
            user-select: none
        }

        .tabscon {
            width: 100%;
            height: 300px;
            position: absolute;
            padding: 30px;
            top: 50px;
            left: 0;
            box-sizing: border-box;
            border-top: 1px solid #ccc
        }

        .tabscon section {
            display: none;
            width: 100%;
            height: 100%
        }

        .tabscon section.conactive {
            display: block
        }
@font-face {
            font-family:iconfont;src:url(./iconfont/iconfont.eot?t=1553960438096);src:url(./iconfont/iconfont.eot?t=1553960438096#iefix) format('embedded-opentype'),url(data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAK4AAsAAAAABmwAAAJrAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCCcAp4fwE2AiQDCAsGAAQgBYRtBzAbpQXIrrApw71oi3CCOyzEy8RvE4yIN8TD036/zp03qCYRjaJZNBFFS/gREoRGipQKofjuNrb+9XbTqrmXcqWzfTRDqFqWkhAJzYToaE6LQ7Q30CirRqSKMnj58DdIdrNAdhoTQJa5VGfLrtiAy+lPoAcZdUC57UljTR4TMAo4oL0xiqwYG8YueIHPCdTqYajty/t+bUpmrwvEnUK42lQhLMssVy1UNhzN4kmF6vSQVvMY/T5+HEU1SUXBbti7uBBrx++cgqJULp0GhAgBna5AgSkgE0eN6R1NwTitNt0yAI5VG7wr/8AljmoX7K+zq+tBF1Q8k9JTPWp1AjnJDgCzmM3bU0V31dsvV3M2eC6fHjaGfX/qS7U5Gr58vj6uD0bgxudyrV/OtHHyP+NZnpO1txbktjdY+3FB61+7nxeOzq8niGYnRwT3v3aZxeXf6rrNxl5//49WlEtZUUL1Pj3Bv1EO7MuG2namrCkbvcnApLUJtWpRhv2tzlRLx43kQ7WO2/FW6c5QqDZEZnYKFeosoVK1NdSa5E/XaVM1Ra7BhAEQmk0kjV5QaLbIzG5U6HRRqTkK1DqJtivrjMT1zJaNnIsihAiyQE3JdbszcW0Xiadzdl4d8UO0HSUGNDNXzl2hifYSO5pPjrorgdjUAAavoa5TKDZVUXD3kuuOOzh70fShvUiN2owtNsRxIREIIiATUCYpGO2aqXy/CxEeHcfuaKrLDiGbQ5kcEMsNIK8M5qCmR3mn8RFHOpcECBtlAAwWIZ2OAqV5kQoJXHvShORYBzrDZKhhb3uT8QPlrA3bmsKZV6i89DiTV2o1AAAA) format('woff2'),url(./iconfont/iconfont.woff?t=1553960438096) format('woff'),url(./iconfont/iconfont.ttf?t=1553960438096) format('truetype'),url(./iconfont/iconfont.svg?t=1553960438096#iconfont) format('svg')
        }

        .iconfont {
            font-family: iconfont!important;
            font-size: 16px;
            font-style: normal;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale
        }

        .icon-guanbi:before {
            content: "\e676"
        }
    </style>
</head>
<body>
    <main>
      .........完整代码请登录后点击上方下载按钮下载查看

网友评论0