Bootstrap 4 vertical tabs and content on right side - html

i'm trying to make a form wizard using bootstrap tabs. The layout is simple
Vertical tabs like a sidebar menu and content on right side
| Tab1 | |
| Tab2 | Content |
| Tab3 | |
To do this i used bootstrap grid but there is a problem, if i reduce browser size the content goes under the tabs.
Is there a way to keep content next to tabs despite the browser size?
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a>
<a class="nav-link" id="v-pills-profile-tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a>
<a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</a>
<a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</a>
</div>
</div>
<div class="col-md-10">
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">
<div class="form-group">
// content
</div>
</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
</div>
</div>
</div>
</div>

Assuming bootstrap 4, just drop the md breakpoint
use col-2 instead of col-md-2
<div class="row">
<div class="col-2"> 2 col content </div>
<div class="col-10"> 10 col content </div>
</div>
https://getbootstrap.com/docs/4.3/layout/overview/#responsive-breakpoints

Instead of col-md-2 and col-md-10, md stands for medium, you should use only col-sm. It will stay in 2 columns on all screens except extra small screens. Or you can use tables.

Related

Is it possible to have a navbar on bootstrap cards when they are dynamically created?

I'm working on a website where I have multiple cards representing a product. I want to have tabs on the top of each card so that the user can see more details; however, when I try doing this, no matter which card I click the tab on, only the very first one changes. I think it is because of the id and aria-controls is the same on each one due to the loop, but I do not know how to fix this. Please help.
UPDATE:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div class="card border-dark mb-3 mx-auto text-center" *ngFor="let p of products">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id='product-tab' data-toggle='tab' role="tab" aria-controls="product" aria-selected="true" href="#product">Product</a>
</li>
<li class="nav-item">
<a class="nav-link" id='user-tab' data-toggle='tab' role="tab" aria-controls="user" aria-selected="false" href="#user">User</a>
</li>
<li class="nav-item">
<a class="nav-link" id='details-tab' data-toggle='tab' role="tab" aria-controls="details" aria-selected="false" href="#details">Details</a>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="product" role="tabpanel" aria-labelledby="product-tab">
<h5 class="card-title">{{p.name}}</h5>
<div role="separator" class="dropdown-divider"></div>
<h6 class="card-subtitle">
<i>{{p.location}} | {{p.quantity}} available</i>
<br>
<small class="text-muted">Uploaded {{p.datePosted | date}}</small>
</h6>
<div role="separator" class="dropdown-divider"></div>
<p class="card-text">{{p.description}}</p>
</div>
<div class="tab-pane fade" id="user" role="tabpanel" aria-labelledby="user-tab">
<h5 class="card-title">{{p.userName}}</h5>
<hr>
<h6 class="card-subtitle">
Contact Information:
</h6>
{{p.phone | phone}} {{p.email}}
<hr>
<h6 class="card-subtitle">
Bell Id:
</h6>
{{p.employeeNumber}}
</div>
<div class="tab-pane fade" id="details" role="tabpanel" aria-labelledby="details-tab">{{p.datePosted}}</div>
</div>
</div>
<div class="card-footer">
<button type="button" class="btn btn-outline-primary" (click)='rejectProduct(p.id)' [routerLink]="['/admin/products']">REJECT</button>
<button type="button" class="btn btn-outline-primary" (click)='approveProduct(p.id)' [routerLink]="['/admin/products']">APPROVE</button>
</div>
</div>
First, remember to include the Bootstrap javascript files if you have not done so already (they are not present in your code example).
Assuming you have the correct Bootstrap files linked, you'll need to give your elements unique IDs on each loop so that your tabs will call the correct tab pane content. To do this, simply declare a variable in the script that generates the cards and append it to the ID in each loop (e.g. id="product-tab-0", id="product-tab-1", etc.).

Tab panes losing width in Bootstrap 4

I've created tabbed content in my project with three tabs. For each tab pane, the pane loses width. For example the first tab pane is the full 100% width, however each pane onwards loses 100-200px consecutively.
For example:
The first pane is 1140px (full width of the container)
The second pane is: 1004px width
The third pane is: 794px width
I've checked for missing divs and I don't believe the use of rows and columns within the tab panes is the cause of the issue. I've also tried setting width: 100% to the tab panes with no luck.
I can't understand why this is happening.
<section class="home-office-types">
<div class="container">
<div class="row">
<div class="col-lg-12">
<ul class="nav nav-tabs home-office-types__tabs" id="myTab" role="tablist">
<li class="nav-item home-office-types__tab">
<a class="nav-link home-office-types__tab-link active" id="managed-offices-tab" data-toggle="tab" href="#managed-offices" role="tab"
aria-controls="managed-offices" aria-selected="true">Serviced & managed offices</a>
</li>
<li class="nav-item home-office-types__tab">
<a class="nav-link home-office-types__tab-link" id="meeting-rooms-tab" data-toggle="tab" href="#meeting-rooms" role="tab"
aria-controls="meeting-rooms" aria-selected="true">Meeting Rooms</a>
</li>
<li class="nav-item home-office-types__tab">
<a class="nav-link home-office-types__tab-link" id="virtual-offices-tab" data-toggle="tab" href="#virtual-offices" role="tab"
aria-controls="virtual-offices" aria-selected="true">Virtual Offices</a>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="tab-content home-office-types__content" id="myTabContent">
<div class="tab-pane fade show active" id="managed-offices" role="tabpanel"
aria-labelledby="managed-offices-tab">
<div class="row">
<div class="col-lg-7 d-flex justify-content-start">
<ul>
<li>State of the art internet & phone packages</li>
<li>Fully furnished and ready for you to move in and make your home</li>
<li>No hidden costs - your monthly fee covers everything from all your utilities to cleaning</li>
<li>Great value and truly affordable prices</li>
<li>No long contracts - choose from a few days to as long as you want giving you total control of your business’ finances</li>
</ul>
</div>
<div class="col-lg-5 d-flex justify-content-end">
<img class="home-office-types__image img-fluid" src="https://placehold.co/304x304" alt="">
</div>
</div>
</div>
<div class="tab-pane fade" id="meeting-rooms" role="tabpanel" aria-labelledby="meeting-rooms-tab">
<div class="row">
<div class="col-lg-7 d-flex justify-content-start">
<ul>
<li>State of the art internet & phone packages</li>
<li>Fully furnished and ready for you to move in and make your home</li>
</ul>
</div>
<div class="col-lg-5 d-flex justify-content-end">
<img class="home-office-types__image img-fluid" src="https://placehold.co/304x304" alt="">
</div>
</div>
</div>
<div class="tab-pane fade" id="virtual-offices" role="tabpanel" aria-labelledby="virtual-offices-tab">
<div class="row">
<div class="col-lg-7 d-flex justify-content-start">
<ul>
<li>State of the art internet & phone packages</li>
</ul>
</div>
<div class="col-lg-5 d-flex justify-content-end">
<img class="home-office-types__image img-fluid" src="https://placehold.co/304x304" alt="">
</div>
</div>
</div>
</div>
</div>
</div>
</section>
Below is the JS Fiddle:
https://jsfiddle.net/graeme95/qo6tj819/2/
.tab-content {
width: 100%;
}
Also noticed that your grid only starts at lg. Mobile first!

Bootstrap 4.3 Tab not switching from the first tab

I've incorporated bootstrap tabs into my web app following the documentation on the bootstrap website.
I've so far managed to get the first tab fade animation to play and show the the other two tabs don't seem to work and I'm quite stumped as to why.
<div id="container-fluid">
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs" role="tablist">
<li id="dashboardTab" class="nav-item">
<a class="nav-link active" id="dashboard-tab" data-toggle="tab" href="#dashboard" role="tab" aria-controls="dashboard" aria-selected="true">Dashboard</a>
</li>
<li id="usersTab" class="nav-item">
<a class="nav-link" id="userCreate-tab" data-toggle="tab" href="#userCreate" role="tab" aria-controls="userCreate" aria-selected="false">Users<span onclick="onCloseTabButtonClick(0)">X</span></a>
</li>
<li id="wholesalerTab" class="nav-item">
<a class="nav-link" id="wholesalerCreate-tab" data-toggle="tab" href="#wholesalerCreate" role="tab" aria-controls="wholesalerCreate" aria-selected="false">Wholesalers<span onclick="onCloseTabButtonClick(1)">X</span></a>
</li>
</ul>
<div class="tab-content">
<div id="dashboard" class="tab-pane fade show active" role="tabpanel" aria-labelledby="dashboard-tab">
<h3>Dash Tab</h3>
<iframe class="iframe-size" id="dashboardHolder" src="Dashboard.aspx" />
</div>
<div class="tab-pane fade" id="userCreate" role="tabpanel" aria-labelledby="userCreate-tab">
<h3>User Tab</h3>
<iframe class="iframe-size" src="UserCreate.aspx" />
</div>
<div id="wholesalerCreate" class="tab-pane fade" role="tabpanel" aria-labelledby="wholesalerCreate-tab">
<h3>Wholesaler Tab</h3>
<iframe class="iframe-size" src="WholsalerCreate.aspx" />
</div>
</div>
</div>
</div>
</div>
Alot of similar questions I've read show that the error is simply not importing the Jquery and the bootstrap js files.
<script src="../Scripts/jquery-3.4.1.min.js"></script>
<script src="../Scripts/bootstrap.min.js"></script>
I have got this in my header and do believe it's working.
Tabs do not work well with Iframes. So remove them. It is also a better user experience.
<div class="tab-content">
<div id="dashboard" class="tab-pane fade show active" role="tabpanel" aria-labelledby="dashboard-tab">
<h3>Dash Tab</h3>
<div class="iframe-size">
...
</div>
</div>
<div class="tab-pane fade" id="userCreate" role="tabpanel" aria-labelledby="userCreate-tab">
<h3>User Tab</h3>
<div class="iframe-size">
...
</div>
</div>
<div id="wholesalerCreate" class="tab-pane fade" role="tabpanel" aria-labelledby="wholesalerCreate-tab">
<h3>Wholesaler Tab</h3>
<div class="iframe-size">
...
</div>
</div>
</div>

What is wrong with my Bootstrap data-toggle implementation?

So I'm trying to implement a data toggle using bootstrap 4.2.1. Following the documentation, I came up with the following code:
<div class="container">
<div class="row bottom-section position-relative">
<ul class="nav nav-pills" role="tablist">
<li class="nav-item">
<a class="nav-link nav-team active text-center" id="team-tab" data-toggle="tab" data-target="#team" aria-controls="team" role="tab" aria-selected="true">Team</a>
</li>
<li class="nav-item">
<a class="nav-link nav-individual text-center" id="individual-tab" data-toggl="tab" data-target="#individual" aria-controls="individual" role="tab" aria-selected="false">Individual</a>
</li>
</ul>
<div class="bottom-section-content col-sm-12">
<div class="tab-content">
<div class="tab-pane active" id="team" role="tabpanel" aria-labelledby="team-tab"><p>asd</p></div>
<div class="tab-pane" id="individual" role="tabpanel" aria-labelledby="individual-tab"><p>sad</p></div>
</div>
</div>
</div>
</div>
I cant't figure out what is wrong, it should be working like this. Am I missing something with the bootstrap js?
I used your code and found that if you are using 4.1.3, this implementation will not work with your current HTML. You have to upgrade your JS to Bootstrap 4.2.1.
Use: https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/js/bootstrap.min.js
Also #elveti is right you misspelled data-toggle.
Working Example using (4.2.1): https://codepen.io/brooksrelyt/pen/zeNVxo

Nested tabs in a pill tab panel not working in Bootstrap

I'm having trouble getting tabs inside of a vertical pill tab panel to work correctly in Bootstrap 4.
Here's a minimal code example:
<html>
<head>
<link href="bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script src="popper.min.js"></script>
<script src="jquery-3.2.1.min.js"></script>
<script src="bootstrap.min.js"></script>
<div class="row">
<div class="col-2">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist">
<a class="nav-link active" data-toggle="pill" href="#v-pills-1" role="tab">Pill 1</a>
<a class="nav-link" data-toggle="pill" href="#v-pills-2" role="tab">Pill 2</a>
<a class="nav-link" data-toggle="pill" href="#v-pills-3" role="tab">Pill 3</a>
</div>
</div>
<div class="col-10">
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade active show" id="v-pills-1" role="tabpanel">
Pill 1 content
<!-- tabs
<ul class="nav nav-tabs nav-fill" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tabs-1" role="tab">Tab 1</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tabs-2" role="tab">Tab 2</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tabs-3" role="tab">Tab 3</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active show" id="tabs-1" role="tabpanel">Tab 1 content</div>
<div class="tab-pane" id="tabs-2" role="tabpanel">Tab 2 content</div>
<div class="tab-pane" id="tabs-3" role="tabpanel">Tab 3 content</div>
</div>
-->
</div>
<div class="tab-pane fade" id="v-pills-2" role="tabpanel">Pill 2 content</div>
<div class="tab-pane fade" id="v-pills-3" role="tabpanel">Pill 3 content</div>
</div>
</div>
</div>
</body>
</html>
The webpage functions correctly, that is the vertical pills work as expected. Once you uncomment the section that gives the first vertical pill a nested tab, the pills do not function correctly. Clicking on Pill 2 and then Pill 3 will results in the content for both pills to be shown.
Why doesn't this work and how can I fix it?
This is a bug in version 4.0.0-beta. It is fixed in version 4.0.0-beta.2:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>