Bootstrap Collapse Question

Bootstrap Collapse Question



1. Index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Collapse</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500|Open+Sans" 
rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap
/4.2.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/
icon?family=Material+Icons"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/
umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/
bootstrap.min.js"></script>
<link rel="stylesheet" href="styles.css">

</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-title">Bootstrap Collapse Question</h1>
            <div class="accordion" id="accordionExample">
                <div class="card">
                    <div class="card-header" id="headingOne">
                        <h2 class="clearfix mb-0">
                            <a class="btn btn-link" data-toggle="collapse" data-                             target="#collapseOne"
                             aria-expanded="true" aria-controls="collapseOne">
                             <i class="fa fa-chevron-circle-down"></i> 
                              What is Bootstrap Framework?
                            </a>                                    
                        </h2>
                    </div>
                    <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" 
                        data-parent="#accordionExample">
                        <div class="card-body">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nam eu sem tempor, varius quam at, luctus dui. Mauris magna metus, dapibus
nec turpis vel, semper malesuada ante. Vestibulum id metus ac nisl bibendum
scelerisque non non purus. Suspendisse varius nibh non aliquet sagittis.
In tincidunt orci sit amet elementum vestibulum.
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-header" id="headingTwo">
                        <h2 class="mb-0">
          <a class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo"
aria-expanded="false" aria-controls="collapseTwo">
                                <i class="fa fa-chevron-circle-down"></i> 
                                How to Create Responsive Website with Bootstrap?
                            </a>
                        </h2>
                    </div>
              <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo"
                        data-parent="#accordionExample">
                        <div class="card-body">
                            Anim pariatur cliche reprehenderit, enim eiusmod high
life accusamus terry richardson ad squid. 3 wolf moon officia aute, non
cupidatat skateboard dolor brunch. Food truck quinoa nesciunt
laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a
bird on it squid single-origin coffee nulla assumenda shoreditch et.
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-header" id="headingThree">
                        <h2 class="mb-0">
<a class="btn btn-link collapsed" data-toggle="collapse"
data-target="#collapseThree" aria-expanded="false"
                                aria-controls="collapseThree">
                                <i class="fa fa-chevron-circle-down"></i> 
Does Bootstrap Framework Provide Cross-browser Support?
                            </a>                     
                        </h2>
                    </div>
                  <div id="collapseThree" class="collapse" aria-labelledby="headingThree"
                        data-parent="#accordionExample">
                        <div class="card-body">

Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Nam eu sem tempor, varius quam at, luctus dui. Mauris magna metus,
dapibus nec turpis vel, semper malesuada ante. Vestibulum id metus ac nisl
bibendum scelerisque non non purus. Suspendisse varius nibh non aliquet
sagittis. In tincidunt orci sit amet elementum vestibulum.
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-header" id="headingFour">
                        <h2 class="mb-0">
         <a class="btn btn-link collapsed" data-toggle="collapse"
                           data-target="#collapseFour" aria-expanded="false" aria-controls="collapseFour">
                                <i class="fa fa-chevron-circle-down"></i> 
                                Can I Use Bootstrap for Mobile App Development?
                            </a>                               
                        </h2>
                    </div>
<div id="collapseFour" class="collapse" aria-       labelledby="headingFour"
                    data-parent="#accordionExample">
                        <div class="card-body">
                            Anim pariatur cliche reprehenderit, enim eiusmod 
high life accusamus terry richardson ad squid. 3 wolf moon officia aute,
non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum
eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid
single-origin coffee nulla assumenda shoreditch et.
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="javascript.js"></script>
</body>
</html>                            


2.styles.css


    body {
        background#fff;
    }
    .accordion .card {
        backgroundnone;
        bordernone;
    }
    .accordion .card .card-header {
        backgroundnone;
        bordernone;
        padding.4rem 1rem;
        font-family"Roboto"sans-serif;
    }
    .accordion .card-header h2 span {
        floatleft;
        margin-top10px;
    }
    .accordion .card-header .btn {
        color#2f2f31;
        font-size1.04rem;
        text-alignleft;
        positionrelative;
        font-weight500;
        padding-left2rem;
    }
    .accordion .card-header i {
        font-size1.2rem;
        font-weightbold;
        positionabsolute;
        left0;
        top9px;
    }
    .accordion .card-header .btn:hover {
        color#ff8300;
    }
    .accordion .card-body {
        color#324353;
        padding0.5rem 3rem;
    }
    .page-title {
        margin3rem 0 3rem 1rem;
        font-family"Roboto"sans-serif;
        positionrelative;
    }
    .page-title::after {
        content"";
        width510px;
        positionabsolute;
        height3px;
        border-radius1px;
        background#73bb2b;
        left0;
        bottom-15px;
    }
    .accordion .highlight .btn {
        color#74bd30;
    }
    .accordion .highlight i {
        transformrotate(180deg);
    }



3.javascript.js

$(document).ready(function(){
    // Add minus icon for collapse element which is open by default
    $(".collapse.show").each(function(){
        $(this).prev(".card-header").addClass("highlight");
    });
    
    // Highlight open collapsed element 
    $(".card-header .btn").click(function(){
        $(".card-header").not($(this).parents()).removeClass("highlight");
        $(this).parents(".card-header").toggleClass("highlight");
    });
});



























Reactions

Post a Comment

0 Comments

close