当前位置:主页 > 网页特效 > 手风琴代码 >

Bootstrap垂直手风琴折叠菜单

发布时间:2018/06/28 来源:互联网 浏览: 关键词:bootstrap 手风琴 
Bootstrap垂直手风琴折叠菜单 Bootstrap垂直手风琴折叠菜单
阿里云

简要教程

这是一款Bootstrap垂直手风琴折叠菜单。该Bootstrap垂直手风琴折叠菜单使用boostrap网格进行布局,并通过对bootstrap面板组进行美化,构建出精美的垂直手风琴折叠菜单效果。

使用方法

在页面中引jquery和bootstrap相关文件。

<linkhref="path/to/css/bootstrap.min.css"rel="stylesheet">
<linkhref="path/to/css/font-awesome.min.css"rel="stylesheet">
<scriptsrc="path/to/js/jquery.min.js"></script>
<scriptsrc="path/to/js/bootstrap.min.js"></script>    

HTML结构

该Bootstrap垂直手风琴折叠菜单的基本HTML结构如下:

<divclass="container">
    <divclass="row">
        <divclass="col-md-offset-3 col-md-6">
            <divclass="panel-group"id="accordion"role="tablist"aria-multiselectable="true">
                <divclass="panel panel-default">
                    <divclass="panel-heading"role="tab"id="headingOne">
                        <h4class="panel-title">
                            <arole="button"data-toggle="collapse"data-parent="#accordion"href="#collapseOne"aria-expanded="true"aria-controls="collapseOne">
                                Section 1
                            </a>
                        </h4>
                    </div>
                    <divid="collapseOne"class="panel-collapse collapse in"role="tabpanel"aria-labelledby="headingOne">
                        <divclass="panel-body">
                            <p>菜单内容1 </p>
                        </div>
                    </div>
                </div>
 
                <divclass="panel panel-default">
                    <divclass="panel-heading"role="tab"id="headingTwo">
                        <h4class="panel-title">
                            <aclass="collapsed"role="button"data-toggle="collapse"data-parent="#accordion"href="#collapseTwo"aria-expanded="false"aria-controls="collapseTwo">
                                Section 2
                            </a>
                        </h4>
                    </div>
                    <divid="collapseTwo"class="panel-collapse collapse"role="tabpanel"aria-labelledby="headingTwo">
                        <divclass="panel-body">
                            <p>菜单内容2</p>
                        </div>
                    </div>
                </div>
 
                <divclass="panel panel-default">
                    <divclass="panel-heading"role="tab"id="headingThree">
                        <h4class="panel-title">
                            <aclass="collapsed"role="button"data-toggle="collapse"data-parent="#accordion"href="#collapseThree"aria-expanded="false"aria-controls="collapseThree">
                                Section 3
                            </a>
                        </h4>
                    </div>
                    <divid="collapseThree"class="panel-collapse collapse"role="tabpanel"aria-labelledby="headingThree">
                        <divclass="panel-body">
                            <p>菜单内容3</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

CSS样式

然后通过下面的CSS代码来对该Bootstrap垂直手风琴折叠菜单进行效果美化。

a:hover,a:focus{
    text-decoration:none;
    outline:none;
}
#accordion .panel{
    border:none;
    box-shadow:none;
    border-radius:0;
    margin:0015px10px;
}
#accordion .panel-heading{
    padding:0;
    border-radius:30px;
}
#accordion .panel-title a{
    display:block;
    padding:12px20px12px50px;
    background:#ebb710;
    font-size:18px;
    font-weight:600;
    color:#fff;
    border:1pxsolidtransparent;
    border-radius:30px;
    position:relative;
    transition:all0.3s ease0s;
}
#accordion .panel-title a.collapsed{
    background:#fff;
    color:#0d345d;
    border:1pxsolid#ddd;
}
#accordion .panel-title a:after,
#accordion .panel-title a.collapsed:after{
    content:"\f107";
    font-family: fontawesome;
    width:55px;
    height:55px;
    line-height:55px;
    border-radius:50%;
    background:#ebb710;
    font-size:25px;
    color:#fff;
    text-align:center;
    border:1pxsolidtransparent;
    box-shadow:03px10pxrgba(0,0,0,0.58);
    position:absolute;
    top:-5px;
    left:-20px;
    transition:all0.3s ease0s;
}
#accordion .panel-title a.collapsed:after{
    content:"\f105";
    background:#fff;
    color:#0d345d;
    border:1pxsolid#ddd;
    box-shadow:none;
}
#accordion .panel-body{
    padding:20px25px10px9px;
    background:transparent;
    font-size:14px;
    color:#8c8c8c;
    line-height:25px;
    border-top:none;
    position:relative;
}
#accordion .panel-body p{
    padding-left:25px;
    border-left:1pxdashed#8c8c8c;
}        

共有人阅读,期待你的评论!评论
Top