テレットブログ

【Bootstrap】checkbox利用による複数選択ボタンサンプル

2020年06月05日
image

checkbox利用による複数選択ボタンサンプル

toggle不使用
checkboxで複数選択をスマートに利用する
クリックで選択にて選択可能


 

See the Pen multiple botton by terreto (@terreto) on CodePen.



 
<div class="container">
    <h2>Multiple items selector with filter</h2>
    <div class="row">
        <div class="form-group">
            <div class="items-collection">

                <div class="items col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <div class="info-block block-info clearfix">
                        <div data-toggle="buttons" class="btn-group bizmoduleselect">
                            <label class="btn btn-default">
                                <div class="itemcontent">
                                    <input type="checkbox" name="var_id[]" autocomplete="off" value="">
                                    <span class="fa fa-car fa-2x"></span>
                                    <h5>car</h5>
                                </div>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="items col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <div class="info-block block-info clearfix">
                        <div data-toggle="buttons" class="btn-group itemcontent">
                            <label class="btn btn-default">
                                <div class="itemcontent">
                                    <input type="checkbox" name="var_id[]" autocomplete="off" value="">
                                    <span class="fa fa-truck fa-2x"></span>
                                    <h5>truck</h5>
                                </div>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="items col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <div class="info-block block-info clearfix">
                        <div data-toggle="buttons" class="btn-group itemcontent">
                            <label class="btn btn-default">
                                <div class="itemcontent">
                                    <input type="checkbox" name="var_id[]" autocomplete="off" value="">
                                    <span class="fa fa-laptop fa-2x"></span>
                                    <h5>laptop</h5>
                                </div>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="items col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <div class="info-block block-info clearfix">
                        <div data-toggle="buttons" class="btn-group itemcontent">
                            <label class="btn btn-default">
                                <div class="itemcontent">
                                    <input type="checkbox" name="var_id[]" autocomplete="off" value="">
                                    <span class="fa fa-cube fa-2x"></span>
                                    <h5>cube</h5>
                                </div>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="items col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <div class="info-block block-info clearfix">
                        <div data-toggle="buttons" class="btn-group itemcontent">
                            <label class="btn btn-default">
                                <div class="itemcontent">
                                    <input type="checkbox" name="var_id[]" autocomplete="off" value="">
                                    <span class="fa fa-lock fa-2x"></span>
                                    <h5>secure</h5>
                                </div>
                            </label>
                        </div>
                    </div>
                </div>                
                <div class="items col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <div class="info-block block-info clearfix">
                        <div data-toggle="buttons" class="btn-group itemcontent">
                            <label class="btn btn-default">
                                <div class="itemcontent">
                                    <input type="checkbox" name="var_id[]" autocomplete="off" value="">
                                    <span class="fa fa-barcode fa-2x"></span>
                                    <h5>barcode</h5>
                                </div>
                            </label>
                        </div>
                    </div>
                </div>                
                <div class="items col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <div class="info-block block-info clearfix">
                        <div data-toggle="buttons" class="btn-group itemcontent">
                            <label class="btn btn-default">
                                <div class="itemcontent">
                                    <input type="checkbox" name="var_id[]" autocomplete="off" value="">
                                    <span class="fa fa-key fa-2x"></span>
                                    <h5>key</h5>
                                </div>
                            </label>
                        </div>
                    </div>
                </div>                
                <div class="items col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <div class="info-block block-info clearfix">
                        <div data-toggle="buttons" class="btn-group itemcontent">
                            <label class="btn btn-default">
                                <div class="itemcontent">
                                    <input type="checkbox" name="var_id[]" autocomplete="off" value="">
                                    <span class="fa fa-keyboard-o fa-2x"></span>
                                    <h5>keyboard</h5>
                                </div>
                            </label>
                        </div>
                    </div>
                </div>                

            </div>
        </div>
    </div>
    <div class="row">
        <br>
        <div class="form-group">
            <div class="col-sm-12 col-md-12 col-lg-12">                
                <i class="fa fa-search fa-2x pull-left searchicon"></i><input type="search" class="form-control" id="search" placeholder="Filter items...">
            </div>
        </div>
    </div>    
</div>

<style>
#search {
    width:90%;
}

.searchicon {
    color:#5CB85C;
}

.items-collection{
    margin:20px 0 0 0;
}
.items-collection label.btn-default.active{
    background-color:#007ba7;
    color:#FFF;
}
.items-collection label.btn-default{
    width:90%;
    border:1px solid #305891;
    margin:5px; 
    border-radius: 17px;
    color: #305891;
}
.items-collection label .itemcontent{
    width:100%;
}
.items-collection .btn-group{
    width:90%
}
</style>

<script>
$(function () {
    $('#search').on('keyup', function () {
        var pattern = $(this).val();
        $('.items-collection .items').hide();
        $('.items-collection .items').filter(function () {
            return $(this).text().match(new RegExp(pattern, 'i'));
        }).show();
    });
});
</script>






新着記事

image

conoha vps で postfix にDKIMをセットする

2025年06月02日
# メールサーバー設定作業レポート ## 1. 作業概要 ConoHa
Read more →
image

shopipyのページネーションについて

2023年11月15日
Shopify APIのレスポンスヘッダーには、ページネーションに関す
Read more →
image

Git-ftpを使ったファイルアップロードの方法

2023年04月20日
タイトル: Git-ftpを使ったファイルアップロードの方法 概要
Read more →
image

ChatGPTとjQueryの組み合わせで新しい時代のウェブ開発をリード

2023年04月19日
近年、AI技術がウェブ開発の分野においても急速に浸透しています。特に、ChatG
Read more →
image

ChatGPTで日本語をマスター!次世代AI技術を活用したコミュニケーションの強化

2023年04月18日
ChatGPTは、OpenAIが開発した最先端のAI技術であり、自然言語処理(N
Read more →
Choose Colour