I am using a bootstrap collapse functionality to show/hide some statistics, opens like a charm, but when closing, it does no animation and the arrow does not turn back down. What am I missing?
<div class="columna">
<section class="stadisticCard">
<div class="card chart-card">
<div class="card-body pb-0">
<h5 class="card-title font-weight-bold">Amount of food wasted each season in Spain</h5>
<p class="card-text float-left">Spanish Government • 2020</p>
<div class="float-right">
<button class="botonExpandir collapsed" type="button" data-toggle="collapse" data-target="#multiCollapseExample1" aria-expanded="false" aria-controls="multiCollapseExample1">
<i class="bi bi-arrow-up-circle"></i>
</button>
</div>
</div>
<div class="collapse multi-collapse" id="multiCollapseExample1">
<div class="card-body">
<ul class="nav nav-tabs nav-fill mb-3" id="pills-tab1" role="tablist">
<li class="nav-item ms-0" role="presentation">
<a class="linkStadisticas nav-link active" id="pills-home-tab1" data-toggle="pill" href="#pills-home1" role="tab" aria-controls="pills-home1" aria-selected="true">Statistics</a>
</li>
<li class="nav-item">
<a class="linkStadisticas nav-link" id="pills-profile-tab1" data-toggle="pill" href="#pills-profile1" role="tab" aria-controls="pills-profile1" aria-selected="false">Information</a>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content" id="pills-tabContent1">
<div class="tab-pane fade show active" id="pills-home1" role="tabpanel" aria-labelledby="pills-home-tab1">
<canvas id="lineChart" class="lineChart" width="100%" height="100%"></canvas>
</div>
<div class="tab-pane fade" id="pills-profile1" role="tabpanel" aria-labelledby="pills-profile-tab1">
<p class=" textoStadisticas font-small text-muted mx-1">
Information about the statistics
</p>
</div>
</div>
</div>
</div>
</section>
</div>
You have to target [aria-expanded="true"] / [aria-expanded="false"] for expand/collapse Icon UI:
.botonExpandir[aria-expanded="true"] i::before {
content: "\f13a";
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.3.0/font/bootstrap-icons.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="columna">
<section class="stadisticCard">
<div class="card chart-card">
<div class="card-body pb-0">
<h5 class="card-title font-weight-bold">Amount of food wasted each season in Spain</h5>
<p class="card-text float-left">Spanish Government • 2020</p>
<div class="float-right">
<button class="botonExpandir collapsed" type="button" data-toggle="collapse" data-target="#multiCollapseExample1" aria-expanded="false" aria-controls="multiCollapseExample1">
<i class="bi bi-arrow-down-circle"></i>
</button>
</div>
</div>
<div class="collapse multi-collapse" id="multiCollapseExample1">
<div class="card-body">
<ul class="nav nav-tabs nav-fill mb-3" id="pills-tab1" role="tablist">
<li class="nav-item ms-0" role="presentation">
<a class="linkStadisticas nav-link active" id="pills-home-tab1" data-toggle="pill" href="#pills-home1" role="tab" aria-controls="pills-home1" aria-selected="true">Statistics</a>
</li>
<li class="nav-item">
<a class="linkStadisticas nav-link" id="pills-profile-tab1" data-toggle="pill" href="#pills-profile1" role="tab" aria-controls="pills-profile1" aria-selected="false">Information</a>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content" id="pills-tabContent1">
<div class="tab-pane fade show active" id="pills-home1" role="tabpanel" aria-labelledby="pills-home-tab1">
<canvas id="lineChart" class="lineChart" width="100%" height="100%"></canvas>
</div>
<div class="tab-pane fade" id="pills-profile1" role="tabpanel" aria-labelledby="pills-profile-tab1">
<p class=" textoStadisticas font-small text-muted mx-1">
Information about the statistics
</p>
</div>
</div>
</div>
</div>
</section>
</div>
Related
Basically, I am new to HTML and learning how to make a website and I'd like to put two bootstrap cards side by side on the page with a blank space in the middle to separate the two.
When I put both the cards in they automatically go underneath one another instead of side by side. I tried deleting and adding the column again, I tried tweaking the card sizes but can't think or find anything to solve the issue.
Below is the code for the entire site and a picture of how it appears on the site (It's a bit long sorry).
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<title>Form builder</title>
</head>
<body>
<div>
<!-- Script -->
<script src="jquery.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
<script src="bootbox/bootbox.js"></script>
</div>
<!-- Title for page
<div class="container">
<nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Form Builder</a>
</div>
</nav>
</div> -->
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-lg bg-primary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Site</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Kelsey</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Site</a>
</li>
<!-- Dropdown Menu -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle col-6" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Form Settings</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">yo 2 yo</a></li>
<li><a class="dropdown-item" href="#">Add Section</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Form Settings</a></li>
</ul>
</li>
<!-- No Clue what this is
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li> -->
</ul>
<!-- Search bar (Not in use)
<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button></form> -->
</div>
</div>
<!-- End of Nav Bar-->
</nav>
<!-- Tabs -->
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Create Form</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Form Settings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Save Form</a>
</li>
<li class="nav-item">
<a class="nav-link">Form Toolbar</a>
</li>
</ul>
<!-- FIRST ROW FIRST PANEL-->
<div id="create-form">
<div class="row" style="padding-top: 20px;"></div>
<div class="row" style="padding-bottom: 20px;">
<div class="col-md-1"></div>
<div class="col-md-4">
<div class="card">
<div class="card-header">
HEADER PANEL
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item"> 1</li>
<li class="list-group-item">0</li>
<li class="list-group-item">8</li>
</ul>
</div>
</div>
<!-- SECOND PANEL -->
<div class="col-md-2"></div>
<div class="col-md-4">
<div class="card">
<div class="card-header">
PANEL
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
</div>
</div>
</div>
<!-- SECOND ROW 3RD PANEL-->
<div class="card text-bg-primary mb-3 col-md-4">
<div class="card-header">Header</div>
<div class="card-body">
<h5 class="card-title"></h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
<!-- Experimental card -->
<div class="card text-bg-dark mb-3 col-md-4">
<div class="card-header">SCORING MATRIX</div>
<div class="card-body">
<h5 class="card-title"></h5>
<p class="card-text">This can be used to rate processes and experiences.</p>
</div>
</div>
</div>
<!-- 4TH PANEL -->
<!-- <div class="col-md-2"></div>
<div class="col-md-4">
<div class="card" >
<div class="card-header">
SCORING MATRIX
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
</div>
</div>
</div>
</div> -->
<!-- <div class="row">
<div class="col">
<input class="form-control">
</div>
<div class="col">
<input type="text" class="form-control">
</div>
</div> -->
<!-- Moola button <button class="btn btn-info">Moola</button> -->
<!-- End of Navigation Bar -->
<!-- Content -->
<!-- <script src="jquery.min.js"></script> -->
<!-- Bootstrap -->
<!-- <div class="container">
<div class="row">
<div class="col">
1 of 3
</div>
<div class="col-6">
2 of 3 (wider)
</div>
<div class="col">
3 of 3
</div>
</div>
<div class="row">
<div class="col">
1 of 3
</div>
<div class="col-5">
2 of 3 (wider)
</div>
<div class="col">
3 of 3
</div></div></div> -->
<!-- Bootstrap Modal -->
<!--<div class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">1088</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>yo</p>
</div>
<div class="modal-footer">
<button type="button" class="btn-close btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn-save btn btn-primary">Save changes</button>
</div>
</div>
</div></div> -->
<!-- Moola button-->
<!-- <button type="button" class="btn btn-dark" id="btn-openmodal">Moola</button> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
<script src="bootbox/bootbox.js"></script>
<script src="script.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</body>
</html>
</div>
I think the problem is that you use your col-md-x on your cards.
Maybe try wrapping the cards in a col container like this:
<div class="col-md-4">
<div class="card ...">
...
</div>
</div>
My tab panels have problem with content width - it doesnt work with columns - it can't divide a tab-pane as col-md-7 and col-md-5 (look at screen below). I dont know how to make it works.
<div class="container py-5">
<div class="row py-3">
<div class="col-lg-12">
<div class="card h-100">
<div class="card-header py-3"><b>Działalność</b> | Zarządzanie</div>
<div class="card-body">
<div id="zarzadzanie" class="zarzadzanie d-flex align-items-start">
<div class="nav flex-column nav-pills me-5" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<button class="nav-link active my-2" id="v-pills-home-tab" data-bs-toggle="pill" data-bs-target="#v-pills-home" type="button" role="tab" aria-controls="v-pills-home" aria-selected="true">
Podstawowe</button>
<button class="nav-link my-2" id="v-pills-profile-tab" data-bs-toggle="pill" data-bs-target="#v-pills-profile" type="button" role="tab" aria-controls="v-pills-profile" aria-selected="false">
Kolorystyka</button>
<button class="nav-link my-2" id="v-pills-messages-tab" data-bs-toggle="pill" data-bs-target="#v-pills-messages" type="button" role="tab" aria-controls="v-pills-messages" aria-selected="false">
Adresy</button>
<button class="nav-link my-2" id="v-pills-settings-tab" data-bs-toggle="pill" data-bs-target="#v-pills-settings" type="button" role="tab" aria-controls="v-pills-settings" aria-selected="false">
Historia</button>
</div>
<!-- TAB-CONTENT -->
<div class="tab-content" id="v-pills-tabContent">
<!-- Ustawienia 1 --->
<div class="tab-pane fade show active pt-2" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">
<div class="row pb-2">
<div class="col-md-7">
<p>Tabs can be used to contain </p>
</div>
<div class="col-md-5">dsdas</div>
</div>
</div>
<!-- Ustawienia 2 --->
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">
</div>
<!-- Ustawienia 3 --->
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">
</div>
<!-- Ustawienia 4 --->
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">
</div>
<!-- END TAB-CONTENT-->
</div>
<!-- </> END TAB-CONTENT-->
</div>
</div>
</div>
</div>
</div>
</div>
I would be very grateful for your help guys.
Problem on image
I added w-100 to every parent and it works. To the tab-content and the tab-pane
I want to create cards in a row with dropdown. But when one card collapses, height of all other card changes corresponding the first one. How can I prevent that? I want to expand only the selected card. Here is my code:
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row mr-0 ml-0">
<div class="card" style="width: 18rem;">
<div class="card-header">
1
</div>
<div class="card-body">
<h5 class="card-title">First card <i class="fas fa-info-circle fa-x info" data-toggle="collapse" href="#collapseExample1" role="button" aria-expanded="false" aria-controls="collapseExample"></i></h5>
<h6 class="card-subtitle mb-2 text-muted">9/10/2020</h6>
</div>
<div class="collapse" id="collapseExample1">
<ul class="list-group list-group-flush">
<li class="list-group-item">t1</li>
<li class="list-group-item">t2</li>
<li class="list-group-item">t3</li>
<li class="list-group-item">t4</li>
</ul>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">Price</li>
</ul>
</div>
<div class="card" style="width: 18rem;">
<div class="card-header">
2
</div>
<div class="card-body">
<h5 class="card-title">Second card <i class="fas fa-info-circle fa-x info" data-toggle="collapse" href="#collapseExample2" role="button" aria-expanded="false" aria-controls="collapseExample"></i></h5>
<h6 class="card-subtitle mb-2 text-muted">9/10/2020</h6>
</div>
<div class="collapse" id="collapseExample2">
<ul class="list-group list-group-flush">
<li class="list-group-item">t1</li>
<li class="list-group-item">t2</li>
<li class="list-group-item">t3</li>
<li class="list-group-item">t4</li>
</ul>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">Price</li>
</ul>
</div>
</div>
You can add this class align-items-start to <div class="row mr-0 ml-0">. This will prevent the height of all cards from expansion when expanding one.
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="row align-items-start mr-0 ml-0">
<div class="card" style="width: 18rem;">
<div class="card-header">
1
</div>
<div class="card-body">
<h5 class="card-title">First card <i class="fas fa-info-circle fa-x info" data-toggle="collapse" href="#collapseExample1" role="button" aria-expanded="false" aria-controls="collapseExample"></i></h5>
<h6 class="card-subtitle mb-2 text-muted">9/10/2020</h6>
</div>
<div class="collapse" id="collapseExample1">
<ul class="list-group list-group-flush">
<li class="list-group-item">t1</li>
<li class="list-group-item">t2</li>
<li class="list-group-item">t3</li>
<li class="list-group-item">t4</li>
</ul>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">Price</li>
</ul>
</div>
<div class="card" style="width: 18rem;">
<div class="card-header">
2
</div>
<div class="card-body">
<h5 class="card-title">Second card <i class="fas fa-info-circle fa-x info" data-toggle="collapse" href="#collapseExample2" role="button" aria-expanded="false" aria-controls="collapseExample"></i></h5>
<h6 class="card-subtitle mb-2 text-muted">9/10/2020</h6>
</div>
<div class="collapse" id="collapseExample2">
<ul class="list-group list-group-flush">
<li class="list-group-item">t1</li>
<li class="list-group-item">t2</li>
<li class="list-group-item">t3</li>
<li class="list-group-item">t4</li>
</ul>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">Price</li>
</ul>
</div>
</div>
I am having issues with my grid in bootstrap. I am trying to create a nav with side by side and an image. The image on the left and text on the right with the nav on the top. I tried using
<div class="row">
<div class="col">
But it doesn't work to give me my desired result.
My desired result:
.
My code:
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<h1 class="text-center">About Me</h1>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a aria-controls="nav-info" aria-selected="true" class="nav-item nav-link active" data-toggle="tab" href="#nav-info" id="nav-info-tab" role="tab"><i class="fas fa-info"></i> General Info</a> <a aria-controls="nav-experience" aria-selected="false"
class="nav-item nav-link" data-toggle="tab" href="#nav-experience" id="nav-experience-tab" role="tab"><i aria-hidden="true" class="fa fa-user"></i> Experience</a> <a aria-controls="nav-education" aria-selected="false" class="nav-item nav-link" data-toggle="tab"
href="#nav-education" id="nav-education-tab" role="tab"><i aria-hidden="true" class="fa fa-university"></i> Education</a> <a aria-controls="nav-work" aria-selected="false" class="nav-item nav-link" data-toggle="tab" href="#nav-work" id="nav-work-tab"
role="tab"><i aria-hidden="true" class="fa fa-book"></i> Work</a>
</div>
</nav>
<div class="row">
<div class="col">
<div class="tab-content" id="nav-tabContent">
<div class="col-sm-6">
<div class="text-center"><img alt="avatar edgaraxe" class="img-fluid rounded-circle wow fadeIn" data-wow-delay="1s" src="http://icons.iconseeker.com/png/fullsize/black-power-emoticons/anger-512x512.png"></div>
</div>
</div>
<div aria-labelledby="nav-info-tab" class="tab-pane fade show active" id="nav-info" role="tabpanel">
</div>
<div aria-labelledby="nav-experience-tab" class="tab-pane fade" id="nav-experience" role="tabpanel">
<i class="fas fa-language"></i> <b>Languages</b>
<div aria-labelledby="nav-education-tab" class="tab-pane fade" id="nav-education" role="tabpanel">
<i class="fas fa-university"></i> <b>Alma mater</b><br>
</div>
<div aria-labelledby="nav-work-tab" class="tab-pane fade" id="nav-work" role="tabpanel">
<i class="fas fa-briefcase"></i> <b>Freelancer.com</b><br>
</div>
</div>
</div>
</div>
Here, working code with image on the left and text on the right with the nav on the top:
<div class="container">
<h1 class="text-center">About Me</h1>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a aria-controls="nav-info" aria-selected="true" class="nav-item nav-link active" data-toggle="tab" href="#nav-info" id="nav-info-tab" role="tab"><i class="fas fa-info"></i> General Info</a> <a aria-controls="nav-experience" aria-selected="false"
class="nav-item nav-link" data-toggle="tab" href="#nav-experience" id="nav-experience-tab" role="tab"><i aria-hidden="true" class="fa fa-user"></i> Experience</a> <a aria-controls="nav-education" aria-selected="false" class="nav-item nav-link" data-toggle="tab"
href="#nav-education" id="nav-education-tab" role="tab"><i aria-hidden="true" class="fa fa-university"></i> Education</a> <a aria-controls="nav-work" aria-selected="false" class="nav-item nav-link" data-toggle="tab" href="#nav-work" id="nav-work-tab"
role="tab"><i aria-hidden="true" class="fa fa-book"></i> Work</a>
</div>
</nav>
<div class="tab-content" style="display: inline-block" id="nav-tabContent">
<div class="row">
<div class="col-6">
<img alt="avatar edgaraxe" class="img-fluid rounded-circle wow fadeIn" data-wow-delay="1s" src="http://icons.iconseeker.com/png/fullsize/black-power-emoticons/anger-512x512.png">
</div>
<div class="col-6">
<div aria-labelledby="nav-info-tab" class="tab-pane fade show active" id="nav-info" role="tabpanel">
</div>
<div aria-labelledby="nav-experience-tab" class="tab-pane fade" id="nav-experience" role="tabpanel">
<i class="fas fa-language"></i> <b>Languages</b>
</div>
<div aria-labelledby="nav-education-tab" class="tab-pane fade" id="nav-education" role="tabpanel">
<i class="fas fa-university"></i> <b>Alma mater</b><br>
</div>
<div aria-labelledby="nav-work-tab" class="tab-pane fade" id="nav-work" role="tabpanel">
<i class="fas fa-briefcase"></i> <b>Freelancer.com</b><br>
</div>
</div>
</div>
</div>
</div>
plunker: http://plnkr.co/edit/i4YBtRTL6QCUhjoWboNq?p=preview
I am building a single page application for a ESP32. I thought it would be nice to have the whole site in one document since there is not much content.
I started with bootstrap 4.1.2 collapse class. It's working but unfortunately there is something I cannot turn off.
As there is always just one content shown it should not be possible to hide it with a click on the corresponding nav-link, only toggle with other content over a different nav-link should be possible.
So how do I do that?
<!doctype html>
<html lang="en">
<head>
<title>LOGO</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
</head>
<!-- A vertical navbar -->
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-primary">
<div class="container justify-content-center">
<a class="navbar-brand abs " href="#">
<span class="menu-collapsed">LOGO</span>
</a>
<button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarNavDropdown">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse flex-grow text-center" id="navbarNavDropdown">
<ul class="nav navbar-nav flex-fill mx-auto flex-nowrap">
<li class="nav-item">
<a class="nav-link" data-toggle="collapse" data-target="#collapseOne, .navbar-collapse.show"
aria-expanded="true" aria-controls="collapseOne" href="#">TEST1</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="collapse" data-target="#collapseTwo, .navbar-collapse.show"
aria-expanded="false" aria-controls="collapseTwo" href="#">TEST2</a>
</li>
<li class="nav-item">
<a class="nav-link" role="button" data-toggle="collapse" data-target="#collapseThree, .navbar-collapse.show"
aria-expanded="false" aria-controls="collapseThree" href="#">TEST3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i class="fa fa-cog"></i>
<span>Settings</span>
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container" id="accordionExample">
<div class="row">
<div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#accordionExample">
<div class="card-body active">
1111111111111111111111111111111111111
</div>
</div>
</div>
<div class="row">
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
<div class="card-body">
222222222222222222222222222222222222
</div>
</div>
</div>
<div class="row">
<div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample">
<div class="card-body">
333333333333333333333333333333333333
</div>
</div>
</div>
</body>
</html>
just remove the 'show' class from #collapseOne - i think that would solve your issue...
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link href="./css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="./css/fontawesome.css" rel="stylesheet">
<nav class="navbar navbar-expand-md navbar-dark bg-primary">
<div class="container justify-content-center">
<a class="navbar-brand abs " href="#">
<span class="menu-collapsed">LOGO</span>
</a>
<button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarNavDropdown">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse flex-grow text-center" id="navbarNavDropdown">
<ul class="nav navbar-nav flex-fill mx-auto flex-nowrap">
<li class="nav-item">
<a class="nav-link" data-toggle="collapse" data-target="#collapseOne, .navbar-collapse.show" aria-expanded="true"
aria-controls="collapseOne" href="#">TEST1</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="collapse" data-target="#collapseTwo, .navbar-collapse.show" aria-expanded="false"
aria-controls="collapseTwo" href="#">TEST2</a>
</li>
<li class="nav-item">
<a class="nav-link" role="button" data-toggle="collapse" data-target="#collapseThree, .navbar-collapse.show" aria-expanded="false"
aria-controls="collapseThree" href="#">TEST3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i class="fa fa-cog"></i>
<span>Settings</span>
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container" id="accordionExample">
<div class="row">
<div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#accordionExample">
<div class="card-body active">
1111111111111111111111111111111111111
</div>
</div>
</div>
<div class="row">
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
<div class="card-body">
222222222222222222222222222222222222
</div>
</div>
</div>
<div class="row">
<div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample">
<div class="card-body">
333333333333333333333333333333333333
</div>
</div>
</div>
<script src="./js/jquery-3.3.1.slim.min.js" crossorigin="anonymous"></script>
<script src="./js/popper.min.js" crossorigin="anonymous"></script>
<script src="./js/bootstrap.min.js" crossorigin="anonymous"></script>
<script src="./js/fontawesome.js" crossorigin="anonymous"></script>
Got it going, I had to use pills with data-toggle="tab". Just the collapsed menu isn't placing all items vertical like in the first post. But that is just a little design flaw. Thanks for the help :)
<!doctype html>
<html lang="en">
<head>
<title>LOGO</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
</head>
<!-- A vertical navbar -->
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-primary">
<div class="container justify-content-center">
<a class="navbar-brand abs " href="#">
<span class="menu-collapsed">LOGO</span>
</a>
<button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarNavDropdown">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse flex-grow text-center" id="navbarNavDropdown">
<div class="nav nav-pills justify-content-center bg-primary" id="pills-tab" role="navigation" style="margin-top:2.5%;">
<a class="nav-item nav-link text-light active " id="pills-home-tab" data-toggle="tab" href="#pills-home"
role="tab" aria-controls="pills-home" aria-selected="true">
<p class="div" data-toggle="collapse" data-target=".navbar-collapse.show" aria-expanded="false"
aria-controls="collapseThree" href="#">Test1
</p>
</a>
<a class="nav-item nav-link text-light" id="pills-profile-tab" data-toggle="tab" href="#pills-profile"
role="tab" aria-controls="pills-profile" aria-selected="false">
<p class="div" data-toggle="collapse" data-target=".navbar-collapse.show" aria-expanded="false"
aria-controls="collapseThree" href="#">Test2
</p>
</a>
<a class="nav-item nav-link text-light" id="pillsv-contact-tab" data-toggle="tab" href="#pills-contact"
role="tab" aria-controls="pills-contact" aria-selected="false">
<p class="div" data-toggle="collapse" data-target=".navbar-collapse.show" aria-expanded="false"
aria-controls="collapseThree" href="#">Test3
</p>
</a>
</div>
</div>
</nav>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
111111111111111111111111111111111111111111
</div>
<div class="tab-pane" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
222222222222222222222222222222222222222222
</div>
<div class="tab-pane" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">
333333333333333333333333333333333333333333
</div>
</div>
<footer class="fixed-bottom">
Facebook, Twitter usw Symbole
</footer>
</body>
</html>