zoukankan      html  css  js  c++  java
  • bootstrap修改勾选样式

    小对勾需要引入awesome插件。

    css部分:

    .bella-checkbox{
    position: relative;
    }
    /** 将初始的checkbox的样式改变 */
    .bella-checkbox input[type="checkbox"] {
    opacity: 0; /*将初始的checkbox隐藏起来*/
    }

    /** 设计新的checkbox,位置 */
    .bella-checkbox label:before {
    content: '';
    18px;
    height: 18px;
    display: inline-block;
    border-radius: 2px;
    border: 1px solid #bbb;
    background: #fff;
    }

    /** 点击初始的checkbox,将新的checkbox关联起来 */
    .bella-checkbox input[type="checkbox"]:checked + label:after {
    display: inline-block;
    font-family: 'FontAwesome';
    content: "f00c";
    top: 1px;
    left: 0px;
    position: absolute;
    font-size: 10px;
    line-height: 1.7;
    18px;
    height: 18px;
    color: #fff;
    background: #2b94e5;
    border-radius: 2px;
    }

    .bella-checkbox label {
    cursor: pointer;
    text-align: center;
    position: absolute;
    top: 4px;
    left: 10px;
    }

    列表部分:

    配置列表当中
    onPostBody:function(){ //设置复选框的样式,参数id
    onPostBody('apFnodeList');
    },

    js部分:

    function onPostBody(eleId){
    //改变复选框样式
    $('#'+eleId).find("input:checkbox").each(function (i) {
    var $check = $(this);
    if ($check.attr("id") && $check.next("label")) {
    return;
    }
    var name = $(this).attr('id') + $check.attr("name");
    var id = name + "-" + i;
    var $label = $('<label for="'+ id +''+eleId+'"></label>');
    $check.attr("id", id+eleId).parent().addClass("bella-checkbox").append($label);
    });
    }

     样式如下图:

  • 相关阅读:
    jquery点滴总结
    优雅降级和渐进增强的区别
    editplus 常用
    whm 设置共享IP
    php抓取页面的几种方法详解
    上传数据插件 Easy Populate 遇到问题 ?langer=remove
    zencart里常用 SQL
    5个简单的步骤把 WordPress 打造成 CMS
    基于PHP的cURL快速入门
    常用软件、插件名称
  • 原文地址:https://www.cnblogs.com/benmumu/p/10756544.html
Copyright © 2011-2022 走看看