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);
    });
    }

     样式如下图:

  • 相关阅读:
    [UOJ#128][BZOJ4196][Noi2015]软件包管理器
    [UOJ#127][BZOJ4195][NOI2015]程序自动分析
    [BZOJ3653]谈笑风生
    Django 数据库查询优化
    C#中引用(ref关键字)参数
    C#中值参数的使用实例
    静态变量和实例变量
    全局变量和局部变量的理解
    C#方法定义和调用-2
    C#函数的方法定义和方法调用小议
  • 原文地址:https://www.cnblogs.com/benmumu/p/10756544.html
Copyright © 2011-2022 走看看