show content of particular tab as its children - html

I have a list of tabs which can be a category. The content for that specific tab or category should be shown just near and a bit bottom on its respective tab so that it gives a look of parent and children.
Here is how i have done
<div id="teams" class="tabbable tabs-left">
<div class="container">
<div class="row">
<nav class="nav flex-column col-md-1 teamTab" role="tablist" aria-orientation="vertical">
<a class="nav-link active" href="#category1-tab" data-toggle="pill" role="tab">Category1</a>
<a class="nav-link" href="#category2-tab" data-toggle="pill" role="tab">Category2</a>
<a class="nav-link" href="#category3-tab" data-toggle="pill" role="tab">Category3</a>
</nav>
<div class="tab-content col-md-11">
<div class="tab-pane active" id="category1-tab" style="padding-left: 60px; padding-right:100px">
<h5 class="card-title">Name</h5>
<p class="card-title">position</p>
</div>
<div class="tab-pane" id="category2-tab">
<h5 class="card-title">Category 2 Name</h5>
<p class="card-title">position</p>
</div>
<div class="tab-pane" id="category3-tab">
<h5 class="card-title">Category 3 Name</h5>
<p class="card-title">position</p>
</div>
</div>
</div>
</div>
</div>
currently, the content for all tabs is shown at the same place. However, i wanted the content to be shown just beside(with a little bit in bottom position) its respective tab.
--Category 1
name position
Category 2
category 2 name position if clicked this one show in this
position
Category3
similarly if clicked here should be shown its related content
here not on the top

Please try this solution:
Add .child class to all your content DIVs having class .tab-pane and remove inline styles.
.child {
padding-left: 60px;
padding-right:100px
}
Then use this JS code to show Tab content below the Tab title.
$(document).ready(function() {
$('.nav-link').each(function(){
var content_id = $(this).attr('href');
$(this).after($(content_id).hide());
if($(this).hasClass('active')) {
$(content_id).show();
}
});
$('.nav-link').on('click', function(){
var content_id = $(this).attr('href');
$('.tab-pane').hide();
$(content_id).show();
});
});
Hope it will work for you. OR check working code here

Related

How do i incorporate multiple divs inside a bootstrap modal-body?

I'm currently trying to make a single modal with multiple <div> tags inside the modal-body div.
Example based on what i am doing:
HTML:
<div class="modal-body">
<div id="main"> //Main Div or Menu
<div class="card-deck">
<div class="card">
<a href="#" id="gen"> //Gen Trigger
<div class="card-body">
... //Content
</div>
</a>
</div>
<div class="card">
<a href="#" id="light"> //Light Trigger
<div class="card-body">
...
</div>
</a>
</div>
</div>
<div id="gen-content" style="display: none"> //Modal That Gets Triggered.
<div class="card-body p-0 m-0">
<div class="text-right">
<a class="btn btn-danger btn-back" href="#">Back</a>
</div>
Content
</div>
</div>
<div id="light-content" style="display: none"> //Another Modal That Gets Triggered.
<div class="card-body p-0 m-0">
<div class="text-right">
<a class="btn btn-danger btn-back" href="#">Back</a>
</div>
Content
</div>
</div>
</div>
jQuery:
$("#gen").on('click', function() {
$("#main").hide();
$("#gen-content").show();
});
$("#light").on('click', function() {
$("#main").hide();
$("#light-content").show();
});
$(".btn-back").on('click', function(){
$("#gen-content").hide();
$("#main").show();
});
Above code works fine, but clicking the back button scrolls the page way up to the top. And closing it resets it to the original <section>. Is there anything more i can improve with this code? I also think the way i code the content triggers is a bit long.
Found a fix by browsing on the jQuery forums. It read:
use return false; at end of click handler to avoid browser default event on a link. If there is no match to element in href, page will jump to top by default.
I fixed by using:
$("#gen").on('click', function() {
$("#main").hide();
$("#gen-content").show();
return false;
});
$(".btn-back").on('click', function(){
$("#gen-content").hide();
$("#main").show();
return false;
});

How to prevent that vertical pills overlap with tab contents?

I'm using bootstrap 4 in a web application for organizing topography measurements.
On one page, a plot of such a topography is shown in an <div class='tab-content'> element.
There are two navigation pills, "Plot" and "Properties", which allow to select the tab contents.
Here is a simplified version of the original markup:
<div class="container">
<div class="row">
<!-- The leftmost column contain a vertical navigation bar -->
<div class="col-md-1 mb-2 border-right">
<div class="nav nav-pills flex-column" role="tablist" aria-orientation="vertical">
<a class="nav-link active" data-toggle="tab" href="#plot" role="tab">Plot</a>
<a class="nav-link" data-toggle="tab" href="#properties" role="tab">Properties</a>
</div>
</div>
<!-- Columns in the middle change depending on selected pill-->
<div class="col-8">
<div class="tab-content mt-2">
<div class="tab-pane fade active show" id="plot" role="tabpanel" aria-labelledby="plot-tab">
Some plot.
</div>
<div class="tab-pane fade" id="properties" role="tabpanel" aria-labelledby="properties-tab">
Some properties.
</div>
</div>
</div>
<!-- Rightmost 3 columns are a button area -->
<div class="col-3">
<div class="row p-3 pull-right">
<button class="btn btn-primary">
A button
</button>
</div>
</div>
</div>
And here is a fiddle, where you can see it in action.
The pills work, but my problem is that sometimes in my application (depending on the zoom level of my page) and also in the fiddle, the blue background of the selected pill overlaps with the border and with the tab contents:
Could someone give me a hint how to prevent the pills from overlapping, e.g. by CSS?
I would like to have the pills completely on the left of the vertical border.
leftmost column is overflowing the content because of col-1 , you can use bootstrap media query (xs, sm, md, lg, xl) for dividing columns.
<div class="container">
<div class="row">
<!-- The leftmost column contain a vertical navigation bar -->
<div class="col-md-3 col-4 mb-2 border-right">
<div class="nav nav-pills flex-column" role="tablist" aria-orientation="vertical">
<a class="nav-link active" data-toggle="tab" href="#plot" role="tab">Plot</a>
<a class="nav-link" data-toggle="tab" href="#properties" role="tab">Properties</a>
</div>
</div>
<!-- Columns in the middle change depending on selected pill-->
<div class="col-md-6 col-8">
<div class="tab-content mt-2">
<div class="tab-pane fade active show" id="plot" role="tabpanel" aria-labelledby="plot-tab">
Some plot.
</div>
<div class="tab-pane fade" id="properties" role="tabpanel" aria-labelledby="properties-tab">
Some properties.
</div>
</div>
</div>
<!-- Rightmost 3 columns are a button area -->
<div class="col-md-3">
<div class="row p-3 pull-right">
<button class="btn btn-primary">
A button
</button>
</div>
</div>
</div>
</div>

How to open routerLink in next column of the row in angular?

I'm creating a dashboard,and created sidebar menu using bootstrap grid.Now I want when I click any sidebar menu's routerLink. my objective is open that link in next column of the row,as usually happens in dashboards/admin panel.
But here in my case,when I click the link it goes to next page.
<div class="row">
<div class="col-sm-2">
<div class="list-group">
<a routerLink="dashboard" class="list-group-item active"> Dashboard</a>
<div>
<a class = "list-group-item" data-toggle="collapse"
href="#collapse1">Accessories</a>
<div id="collapse1" class="panel-collapse collapse bgColor">
<div class="list-group">
<a routerLink ="add-new" class="list-group-item">Add new Accessory</a>
<a routerLink ="view-accessories" class="list-group-item">View Accessories</a>
</div>
</div>
</div>
</div>
</div>
<div class="col">
</div>
</div>
I expect the output that link should be open in next column of row.
but here in my case it goes to next page. how to resove this.[enter image description here][1]
[1]: https://i.stack.imgur.com/DVyLQ.jpg
That it usually achieved by having a layout where constant elements (like dashboard) are outside the router outlet. Say, in your AppComponent:
<app-navbar></app-navbar>
<app-vertical-nav></app-vertical-nav>
<router-outlet></router-outlet>
<app-footer></app-footer>

Bootstrap tab for buttons?

I have a sign up page divided into two sections. I just want to show each section content hiding in current page when someone click these major buttons. The concept is similar to bootstrap tabs, but I'm not using tabs here. These are simple bootstrap buttons. I tried to play with bootstrap classes with my code but got no luck. I'm using meteor and react.
Screenshot for the image.
"Work and Hire Buttons"
And this is my code
<div id="signup-top-btn">
<div id="myTabs" role="tablist">
<div className="col-xs-6 signup-work-btn">
<button type="button" className="btn btn-block blue-btn active-btn"
data-toggle="tab"
>
Work
</button>
</div>
<div className="col-xs-6 signup-hire-btn">
<button type="button" className="btn btn-primary btn-block blue-btn"
data-toggle="tab" data-target="#employer-signup"
>
Hire
</button>
</div>
</div>
</div>
Any idea?
Make use of the Bootstrap tabs, and style those like:
<!-- Nav tabs -->
<ul class="nav" role="tablist">
<li role="presentation" class="active">Work</li>
<li role="presentation">Hire</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="work">...my working tab</div>
<div role="tabpanel" class="tab-pane" id="hire">...my hiring tab</div>
</div>
Bootply: http://www.bootply.com/CrAGi1Btxj
You can always use JavaScript:
$('button[data-toggle="tab"]').on('click', function(e){
e.preventDefault();
$('.nav-tabs').find('a[href="' + $(this).data('target') + '"]').click();
});

How to create Tabbed Panel in Bootstrap

Which class i need to use for tabbed panel? Is there one?
i do the following and looks bad :-(
A tabbed navigation + a panel with and 0 padding between them-
<div id="dashboardheader" class="container" style="padding-top: 20px;">
<ul class="nav nav-tabs tab-pane">
<li class="active">Dashboard</li>
</ul>
</div>
<div id="dashboardpanel " style="padding-top: 0px">
<div class="panel panel-primary container" style="padding-top: 30px;">
<div class="row">
<div class="col-md-offset-2 col-md-8 col-md-offset-2">
<div class="row">
<img src="..\..\Content/Images/Dashboard/fgh.png" class="btn btn-lg" role="button" onclick="OpenDialog()" />
<img src="..\..\Content/Images/Dashboard/fgh.png" class="btn btn-lg" role="button" />
<img src="..\..\Content/Images/Dashboard/fgh.png" class="btn btn-lg" role="button" />
<img src="..\..\Content/Images/Dashboard/fgh.png" class="btn btn-lg" role="button" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-offset-2 col-md-8 col-md-offset-2">
<div class="row">
<img src="..\..\Content/Images/Dashboard/fgh.png" class="btn btn-lg" role="button" />
<img src="..\..\Content/Images/Dashboard/fgh.png" class="btn btn-lg" role="button" />
<img src="..\..\Content/Images/Dashboard/fgh.png" class="btn btn-lg" role="button" />
</div>
</div>
</div>
</div>
</div>
whats the alternate?
I think what you want is just the regular bootstrap tabs
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="active">Home</li>
<li>Profile</li>
<li>Messages</li>
<li>Settings</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home">...</div>
<div class="tab-pane" id="profile">...</div>
<div class="tab-pane" id="messages">...</div>
<div class="tab-pane" id="settings">...</div>
</div>
Demo in jsFiddle
With a little bit of styling, you can get it to look how you want:
For V4, you'll want to style with the .nav-tabs class and also invoke the tab JavaScript plugin
Here's some simple less you can add that allows you to include .nav.nav-tabs inside a .panel .panel-heading
An example codepen : http://codepen.io/anon/pen/utGaK
IMHO it doesn't quite look as "clean" as the components are when used independently w/o additional styles..
I've tested it with .panel-title too using .pull-right on the .nav. While it worked I found it best to add .clearfix to the header as the tabs are 1/2px too tall ATM. Should be simple to resolve it.
Here's the code I use in the above example.
For example :
<div class="panel panel-default">
<div class="panel-heading">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="active">Home</li>
<li>Profile</li>
<li>Messages</li>
<li>Settings</li>
</ul>
</div>
<!-- Tab panes + Panel body -->
<div class="panel-body tab-content">
<div class="tab-pane active" id="home">HOME</div>
<div class="tab-pane" id="profile">PROFILE</div>
<div class="tab-pane" id="messages">MESSAGES</div>
<div class="tab-pane" id="settings">SET</div>
</div>
</div>
This is the less :
// Need to compensatve for padding in panel-heading
// Must be a way to invert this
// variable - #panel-heading-padding.
#panel-heading-padding-negate: -10px -15px;
.panel {
.panel-heading {
.nav-tabs {
margin:#panel-heading-padding-negate;
border-bottom-width:0;
> li {
> a {
// re-apply the original padding
padding:#panel-heading-padding;
margin-bottom:1px;
border:solid 0 transparent;
&:hover {
border-color: transparent;
}
}
&.active > a {
&,
&:hover,
&:focused {
border:solid 0 transparent;
}
}
}
}
}
}
UPDATE
I've added the following to the li definition and removed the margin-right & border-radius on the > li > a so that when I pull the nav to the right of the header it fits & looks cleaner.
&:first-child > a {
border-top-left-radius:#panel-border-radius;
}
&:last-child > a {
border-top-right-radius:#panel-border-radius;
}
Here's an updated codepen : http://codepen.io/anon/pen/hJsEC
There's a Bootsnipp snippet that does this: http://bootsnipp.com/snippets/MaA0A
It contains CSS to allow embedding tabs in the panel header like this:
<div class="panel with-nav-tabs panel-default">
<div class="panel-heading">
<ul class="nav nav-tabs">
<!--...-->
</ul>
</div>
<div class="panel-body">
<div class="tab-content">
<!--...-->
</div>
</div>
</div>
Result:
Found a simple styling solution based on Andrew Scott's html structure:
.panel-heading>.nav-tabs {
border-bottom: none;
margin-bottom: -10px;
}
<ul class="nav nav-tabs ">
<li class="active" > One </li>
<li > Two <li>
</ul>
<div class="tab-content clearfix">
<div class="tab-pane fade in active" id="One">
This is one
</div>
<div class="tab-pane fade " id="Two">
This is Two
</div>
</div>