CSS+checkbox 实现多选按钮 多选标签

版权声明:本文为博主原创文章,如需转载请附上原文链接。 https://blog.csdn.net/Hi_Boy_/article/details/82791730

效果图:

       

CSS:

input[type="checkbox"] {
        position: absolute;
        clip: rect(0, 0, 0, 0);
    }

    input[type='checkbox'] + label {
        display: block;
        height: 30px;
        padding: 6px 12px;
        font-size: 13px;
        font-weight: 500;
        line-height: 1.428571429;
        /*color: #009aff;*/
        border: 1px solid #ccc;
        text-align: center;
        float: left;
        margin-right: 10px;
        cursor: pointer;
        border-radius: 2px;
    }

     input[type='checkbox']:checked + label {
        /*border: 1px solid #009aff;*/
         background-color: #4dc63c;
         color: #fff;
         border-radius: 2px;
         font-weight: 500;
    }

jsp:

 <c:forEach items="${serve}" var="s">
       <input id="d${s.id}" type="checkbox" data-type="welfare" name="reason">
       <label for="d${s.id}">${s.name}</label>
   </c:forEach>

说明:

${serve}是后台返回的对象集合

没有更多推荐了,返回首页