Bootstrap newbie here.
I am having trouble getting an accordion to work as desired.
I want to achieve a similar look to the offers on the bottom of this site's slider: http://www.christchurch-harbour-hotel.co.uk/
I am struggling to get the divs to align to the bottom of the row so the accordion opens in an upwards direction. I also experienced problems with the positioning elements in the css where both the columns would overlap.
I'm sure it's just a small thing I am missing. Your help would really be appreciated.
Here is a link to the page I am working on: http://crystalsprings.co.za/newsite/
Here is the relevant html:
.specialblock1_header {
background-color: #df4351;
padding: 10px 15px 10px 15px;
color:#FFF;
font-family:Tahoma, Geneva, sans-serif;
font-size:1.2em;
height:100%;
text-align:left;
outline:none;
border:none;
}
.specialblock1_content {
background-color: #FFF;
padding: 10px 15px 10px 15px;
color:#000;
font-family:Tahoma, Geneva, sans-serif;
font-size:1em;
height:100%;
text-align:left;
}
.specialblock2_header {
background-color: #F96;
padding: 10px 15px 10px 15px;
color:#FFF;
font-family:Tahoma, Geneva, sans-serif;
font-size:1.2em;
height:100%;
text-align:left;
}
.accordian_row {
height:400px;
position: relative;
}
.accordian_row .panel-default{
position: absolute;
margin:0;
}
<div class="row accordian_row">
<div class="col-lg-4"></div>
<div class="col-lg-2">
<div class="panel-group" id="accordion1">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion1" href="#collapse1">Planning your honeymoon?</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
<div class="col-lg-2">
<div class="panel-group" id="accordion2">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion2" href="#collapse2">Romance in the misty mountains</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4"></div>
</div>
</div>
Try this CSS code:
.panel-collapse{
position: absolute;
bottom: 37px;
}
.accordion_row .panel-default{
position: relative;
margin:0;
}
Link to working fiddle bin:
Bootstrap Accordion align to bottom of div
You need the change the structure in html in order to achieve upward direction
The #collapse1 div should be put above the .panel-heading
demo
<div class="panel-group" id="accordion1">
<div class="panel panel-default">
<div id="collapse1" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div><div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion1" href="#collapse1" class="collapsed" aria-expanded="false">Planning your honeymoon?</a>
</h4>
</div>
</div>
</div>
You can use table's property to achieve this -
Please see the inline styles I have used,
fiddle
<div class="row accordian_row" style="display: table; width: 100%;">
<div style="display: table-row;">
<div style="display: table-cell; height: 100%; vertical-align: bottom; float: none;" class="col-lg-4"></div>
<div style="display: table-cell; height: 100%; vertical-align: bottom; float: none;" class="col-lg-2">
<div id="accordion1" class="panel-group">
<div style="position: relative;" class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a aria-expanded="true" class="" href="#collapse1" data-parent="#accordion1" data-toggle="collapse">Planning your honeymoon?</a>
</h4>
</div>
<div style="" aria-expanded="true" class="panel-collapse collapse in" id="collapse1">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
<div style="display: table-cell; height: 100%; vertical-align: bottom; float: none;" class="col-lg-2">
<div id="accordion2" class="panel-group">
<div style="position: relative;" class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a aria-expanded="true" class="" href="#collapse2" data-parent="#accordion2" data-toggle="collapse">Romance in the misty mountains</a>
</h4>
</div>
<div style="" aria-expanded="true" class="panel-collapse collapse in" id="collapse2">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
<div style="display: table-cell; height: 100%; vertical-align: bottom; float: none;" class="col-lg-4"></div>
</div>
</div>
.accordian_row .panel-default {
position: absolute;
bottom: 0;
}
.collapse.in, .collapsing {
position: absolute !important;
bottom: 100%;
left: 0;
width: 100%;
}
.panel-group {
margin-bottom: 0;
}
try these codes. it should work fine.
Related
I want my div .valorCard-content to take up space and stop sitting on top of the second section. I want it to continue with a portion on top of the image as an overlay, but I don't want it to cover the second section. How do I take up space and the second section is positioned at the bottom, not being covered by the div .valorCard-content?
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.valorCard {
padding: 0 24px;
position: absolute;
top: 370px;
}
.valorCard-content {
border: 2px solid green;
background-color: white;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
It's generally best to avoid absolute dimensional values in CSS. Instead, use percentages or other relative values. Here you could also do something like calc(100% + 10px) to give a specific top margin.
A better solution might be to nest the elements according to their visual location. If you want an element to overlay another, it should really be that element's child. Of course, you may want a document structure as you have it now for proper text flow.
Protip: Use border rather than rules for visual lines. It keeps your markup cleaner and gives more flexibility. If you're using Bootstrap, use the classes provided.
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.valorCard {
padding: 0 24px;
position: absolute;
top: 100%;
/* <--------------------------- HERE */
}
.valorCard-content {
border: 2px solid green;
background-color: white;
}
.border-bottom {
border-bottom: 1px solid #ddd;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://via.placeholder.com/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4 mb-2 border-bottom">
Lorem Ipsum
</h2>
<div class="valor-lista">
<div class="item border-bottom">
<h4 class="mx-4">Test</h4>
</div>
<div class="item border-bottom">
<h4 class="mx-4">Test</h4>
</div>
<div class="item border-bottom">
<h4 class="mx-4">Test</h4>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
Update as the original answer did not address the issue anymore after OP redacted the question.
To solve the issue now:
reenable .valorCard { position: absolute; top: 370px } (if you disabled it).
add #valorCard-content { margin-bottom: 250px } to move the .second section down from under #valorCard-content (or any value that fits your needs).
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 250px;
}
.valorCard {
padding: 0 24px;
position: absolute;
top: 370px;
}
.valorCard-content {
border: 2px solid green;
background-color: white;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
<!-- </div> -->
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
I'm trying to position my div .valorCard on top of my image. I want the div to have a piece of it on top of the end of the image, I'm using relative position on the image and absolute position on the div and a value on the bottom for that. But the div is covering my second section and I don't want that to happen. Can someone help me? I can't use absolute position in my second section because it ruins the style of it.
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
}
.valorCard {
padding: 0 24px;
position: absolute;
bottom: -190px;
width: 150px;
}
.valorCard-content {
border: 2px solid green;
background-color: grey;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
As I unserstand your explanation I thing this is the behavior that you desire.
Most in common. You already have used the flexbox with a column whih is nice.
If you would like to rearragne the elements inside the flex container there is no need to use the position: absolute. You have to just use the order: NUMBER property to order the elements inside the flex.
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
}
.valorCard {
padding: 0 24px;
bottom: -190px;
width: 60%;
order: 0;
}
.valorImagem {
order: 1;
}
.valorCard-content {
border: 2px solid green;
background-color: grey;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
If I understand your intentions correctly, you can add overflow: hidden; to the css for #valorContent to hide the overflowing part:
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
}
.valorCard {
padding: 0 24px;
position: absolute;
bottom: -190px;
width: 150px;
}
.valorCard-content {
border: 2px solid green;
background-color: grey;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
I want the group's title to be able to expand into a list or tree, with a text character next to the title that is "+" by default, "-" when expanded, and toggles as the list state is displayed and hidden.
How would I accomplish that in bootstrap v.3?
http://jsbin.com/jakofugoxe/edit?html,css,output
.panel-heading[data-toggle="collapse"] {
cursor: pointer;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" data-target="#collapse1">
<h4 class="panel-title">
Collapsible Group 1
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading collapsed" data-toggle="collapse" data-parent="#accordion" data-target="#collapse2">
<h4 class="panel-title">
Collapsible Group 2
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading collapsed" data-toggle="collapse" data-parent="#accordion" data-target="#collapse3">
<h4 class="panel-title">
Collapsible Group 3
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
You can use a :before or :after pseudo element to draw + or -:
The collapsed class must be used with .panel-heading inside all panels except the one that is active. Bootstrap js toggles this class while clicking on panel titles and we can use this to toggle between + and -.
HTML:
<div class="panel panel-default">
<div class="panel-heading collapsed" data-toggle="collapse" data-parent="#accordion" data-target="#collapse2">
<!-- ^^^ This class should be present on panel headings
inside all panels except the one that is active. -->
<h4 class="panel-title">Collapsible Group 2</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet</div>
</div>
</div>
Necessary CSS:
.panel-default>.panel-heading {
padding-right: 30px;
position: relative;
}
.panel-default>.panel-heading:after {
content: '-';
position: absolute;
font-size: 20px;
right: 10px;
top: 50%;
transform: translateY(-50%);
}
.panel-default>.panel-heading.collapsed:after {
content: '+';
}
#import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css");
.panel-heading[data-toggle="collapse"] {
cursor: pointer;
}
.panel-default>.panel-heading {
padding-right: 30px;
position: relative;
}
.panel-default>.panel-heading:after {
content: '-';
position: absolute;
font-size: 20px;
right: 10px;
top: 50%;
transform: translateY(-50%);
}
.panel-default>.panel-heading.collapsed:after {
content: '+';
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" data-target="#collapse1">
<h4 class="panel-title">
Collapsible Group 1
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading collapsed" data-toggle="collapse" data-parent="#accordion" data-target="#collapse2">
<h4 class="panel-title">
Collapsible Group 2
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading collapsed" data-toggle="collapse" data-parent="#accordion" data-target="#collapse3">
<h4 class="panel-title">
Collapsible Group 3
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
Original code is:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Accordion Example</h2>
<p><strong>Note:</strong> The <strong>data-parent</strong> attribute makes sure that all collapsible elements under the specified parent will be closed when one of the collapsible item is shown.</p>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">Collapsible Group 1</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Collapsible Group 2</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse3">Collapsible Group 3</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
</body>
</html>
I am looking to add bullet points before the containers to look something like this.
ScreenShot
I tried adding <ul <li> before <div class="panel panel-default"> and </li> </ul> after <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit....</div>
which works to get the bullet points for each box but then wont allow the boxes to close if another box is clicked other than box one.
Hope someone can help, I have 0 experience with HTML and am doing this as fun so if you dont want to help dont comment.
Thanks
You can use pseudo element :after or :before to get the bullet.
.panel.panel-default:before {
content: '';
position: absolute;
left: -10px;
width: 4px;
height: 4px;
border-radius: 50%;
background: black;
top: 15px;
}
.panel.panel-default {
position: relative;
}
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<h2>Accordion Example</h2>
<p><strong>Note:</strong> The <strong>data-parent</strong> attribute makes sure that all collapsible elements under the specified parent will be closed when one of the collapsible item is shown.</p>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">Collapsible Group 1</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Collapsible Group 2</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse3">Collapsible Group 3</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
i no sure why it is no working. maybe i miss some simple thing== i no sure why what i want is when i use a icon show 1 div than other div will hide.
now is if i click 1st icon show a div if i click the second icon the div will show but the 1st icon div will not hide
here is the example of enter link description here
here is the html code
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="right-lower-container accordion" id="myGroup">
<div class="testing-notification">
<span class="glyphicon glyphicon-comment notification-bar accordion-toggle" data-toggle="collapse" data-target="#testing1" data-parent="#myGroup"></span>
<div id="testing1" class="collapse notification-block">
testing 1
</div>
</div>
<div class="testing-notification">
<span class="btn glyphicon glyphicon-bell notification-bar accordion-toggle" data-toggle="collapse" data-target="#testing2" data-parent="#myGroup"></span>
<div id="testing2" class="collapse notification-block">
testing2
</div>
</div>
<a class="option-font" href="#">
<span>
new items
</span>
</a>
<a class="option-font" href="#">
<span class="glyphicon glyphicon-search">
search
</span>
</a>
</div>
here is my css code
.right-lower-container {
height: 40%;
width: 100%;
display: block;
vertical-align: top;
text-align: right;
}
.notification-bar {
color: black;
margin-right: 2.5%;
}
.notification-bar:hover {
color: gray;
}
.notification-block {
width: 100px;
height: 100px;
}
.testing-notification {
display: inline-block;
width: 20%;
}
#testing1,#testing2{
background-color:red;
width:100px;
height:200px;
}
.option-font,
.notification-bar,
.testing-notification {
display: inline-block;
vertical-align: top;
}
Additional Question
how i style the input type by using bootstrap?
here is the html code
<form method="post" action="">
<input type = "submit" clas="btn btn-default btn-direct-message" value="message" name="chat">
</form>
To style Bootstrap components you need to wrap the input into "form-group" class
<form method="post" action="">
<div class="form-group">
<input type = "submit" clas="btn btn-default btn-direct-message" value="message" name="chat">
</div>
</form>
If You Want To Collapse A div When The Other Gets Open Try The Following
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Accordion Example</h2>
<p><strong>Note:</strong> The <strong>data-parent</strong> attribute makes sure that all collapsible elements under the specified parent will be closed when one of the collapsible item is shown.</p>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">Collapsible Group 1</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Collapsible Group 2</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse3">Collapsible Group 3</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
</body>
</html>