How to style mulitiple bootstrap accordions on one page

I have the accordions working just as i like but i want them in two different colors. I am using the bootstrap 3 code and have created a new css for the main classes. I tried to copy the css and add the additional class but when i do it doesnt work or screws up the layout on the page. any help would be appreciated

.doctor p {
  font-size: .8em;
}

.doctor img {
  width: 100%;
   
}

.doctor .panel-default>.panel-heading{
    color:#6f4e36;
   background-color: #95deae;
  /*background-image: linear-gradient(to bottom, #95deae, #49a5bf);*/
    border-color:transparent;
}
.doctor .panel-heading .accordion-toggle:after {
    /* symbol for "opening" panels */
    font-family: 'Glyphicons Halflings';  /* essential for enabling glyphicon */
    content: "\e114";    /* adjust as needed, taken from bootstrap.css */
    float: right;        /* adjust as needed */
    color: grey;         /* adjust as needed */
}
.doctor .panel-heading .accordion-toggle.collapsed:after {
    /* symbol for "collapsed" panels */
    content: "\e080";    /* adjust as needed, taken from bootstrap.css */
}
.doctor .panel{
    margin-bottom:20px;
    background-color:transparent;
    border: none transparent;
    border-radius:4px;
    -webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);
    box-shadow:0 1px 1px rgba(0,0,0,.05)
}
.doctor .panel-body{
    padding:15px;
	/*background-color: #E4D29D;*/
    background-image:  linear-gradient(to bottom, rgba(246,230,180,1) 0%, rgba(134,199,156,1) 0%, rgba(149,222,174,1) 100%);
}
.doctor .panel-heading{
    padding:10px 15px;
    border-bottom:none transparent;
    border-top-left-radius:3px;
    border-top-right-radius:3px
}
.doctor .panel-heading>.dropdown .dropdown-toggle{
    color:#6f4e36;
}
.doctor .panel h3 {
  font-weight: 600;
  font-size: 1.2em;
  color: #6F4E36;
  padding-bottom: 5px;
}
.doctor .panel-title{
    margin-top:0;
    margin-bottom:0;
    font-size:16px;
    color:#6f4e36;
}
.doctor .panel-title>a{
    color:#6f4e36;
}
.doctor .panel-footer{
    padding:10px 15px;
    background-color:transparent;
    border-top: none ;
    border-bottom-right-radius:3px;
    border-bottom-left-radius:3px
}

Open in new window

Dorinda ReyesSharePoint Developer/SharePoint Migration ExpertAsked:
Who is Participating?
 
Julian HansenConnect With a Mentor Commented:
If you look at an example panel from an accordion (taken from the Bootstrap Javascript page)
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
        <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </a>
      </h4>
    </div>

Open in new window

You will see this
  <div class="panel panel-default">

Open in new window

The panel-default is what gives the style to the heading and panel. You can change that
For example
  <div class="panel panel-primary">

Open in new window

Will change the heading bars to blue as shown in this example

You can create your own panel-custom style by creating the following styles (taken from the Bootstrap CSS file
.panel-custom{
  border-color: #337ab7;
}
.panel-custom > .panel-heading {
  color: #fff;
  background-color: #337ab7;
  border-color: #337ab7;
}
.panel-custom > .panel-heading + .panel-collapse > .panel-body {
  border-top-color: #337ab7;
}
.panel-custom > .panel-heading .badge {
  color: #337ab7;
  background-color: #fff;
}
.panel-custom> .panel-footer + .panel-collapse > .panel-body {
  border-bottom-color: #337ab7;
}

Open in new window

0
 
Juana VillaFront-end DeveloperCommented:
It is hard to tell without seeing the html or a live example.

My guess is that:
1.  You need to add more css to override the code inherited by the original bootstrap styles.
2. Make sure you place the new css after the original bootstrap styles (that way we can override them)
3. Make sure your selector is specific enough to override the inherited styles. Sometimes by adding the type of selector and its name helps. Example: .doctor .panel-title vs div.doctor .panel-title (the second one will override the first one)
0
 
Slick812Connect With a Mentor Commented:
greetings  Dorinda Reyes, , , , In order to get separate accordion panel-collapse panels with different backgrounds, you can use the panel-collapse   ID   in the CSS

if you have two panels like -
    <div id="panel1" class="panel-collapse collapse in">
    <div id="panel2" class="panel-collapse collapse in">

you can use CSS like -
<style>

    #panel1 {background-image: linear-gradient(to bottom, #95deae, #49a5bf);}

    #panel2 {background: green;}

</style>

Open in new window

0
 
Slick812Commented:
this question has been inactive for 14 days and must be closed, points divided between experts
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.