How to create Tabbed Panel in Bootstrap - html

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>

Related

Menu going down together with scrolling the page

I have this code:
.navbar-default .navbar-nav>li>a {
width: auto;
/* width: 200px;*/
/* font-weight: bold;*/
}
.mega-dropdown {
position: static !important;
/* width: 100%;*/
}
.mega-dropdown-menu {
padding: 0px;
width: 100%;
box-shadow: none;
-webkit-box-shadow: none;
}
.mega-dropdown-menu > li > ul {
padding: 0;
margin: 0;
}
.mega-dropdown-menu > li > ul > li {
list-style: none;
}
.mega-dropdown-menu > li > ul > li > a {
display: block;
padding: 3px 20px;
clear: both;
font-weight: 300;
line-height: 1.428571429;
color: #243C78;
white-space: normal;
}
.mega-dropdown-menu .dropdown-header {
color: #243C78;
font-size: 18px;
font-weight: 500;
}
.mega-dropdown-menu form {
margin: 3px 20px;
}
.mega-dropdown-menu .form-group {
margin-bottom: 3px;
}
<section class="indexTop">
<div class="container">
<div class="row indexTopPadding">
<div class="col-xs-8 col-sm-12 col-md-12 col-lg-11 ">
<div class="topData">Poniedziałek, 11 października 2019</div>
</div>
<div class="col-xs-4 col-sm-12 col-md-12 col-lg-1">
<div class="topKontrast">
<img src="images/ikon2.png" class="img-responsive topIkonLeft topIkonLeft5">
<img src="images/ikon1.png" class="img-responsive topIkonLeft topIkonLeft5">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-3 topMargin15 visible-xs">
<div class="topSocialMedia">
<img src="images/ikon7.png" class="img-responsive topIkonLeft topIkonLeft10 ikonSocialMediaR">
<img src="images/ikon3.png" class="img-responsive topIkonLeft topIkonLeft10 ikonSocialMediaR">
<img src="images/ikon4.png" class="img-responsive topIkonLeft topIkonLeft10 ikonSocialMediaR">
<img src="images/ikon5.png" class="img-responsive topIkonLeft topIkonLeft10 ikonSocialMediaR">
<img src="images/ikon6.png" class="img-responsive topIkonLeft topIkonLeft10 ikonSocialMediaR">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-5 topMargin30R ">
<div class="logo">
<img src="images/logo.png" class="img-responsive ikonCenterR">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4 topMargin10 hidden-xs">
<form method="post" name="contactformXX" class="form validate clearfix validate-form">
<div class="form-group ">
<div class="form-group has-feedback ">
<input type="text" class="form-control indexInputSzukaj" id="inputValidation" placeholder="Znajdź" /> <span class="glyphicon glyphicon-search form-control-feedback glyphiconColor"></span> </div>
</div>
</form>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-3 topMargin15 hidden-xs">
<div class="topSocialMedia">
<img src="images/ikon7.png" class="img-responsive topIkonLeft topIkonLeft10">
<img src="images/ikon3.png" class="img-responsive topIkonLeft topIkonLeft10">
<img src="images/ikon4.png" class="img-responsive topIkonLeft topIkonLeft10">
<img src="images/ikon5.png" class="img-responsive topIkonLeft topIkonLeft10">
<img src="images/ikon6.png" class="img-responsive topIkonLeft topIkonLeft10">
</div>
</div>
</div>
</div>
</section>
<!-- END TOP-->
<!-- MENU-->
<div class="paddingMenuTop"></div>
<nav class="navbar navbar-default navbarDefaultMop ">
<div class="container">
<!-- navbar-fixed-top -->
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".js-navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand visible-xs" href="#">MegaMenu</a></div>
<div class="collapse navbar-collapse js-navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown menuMop"> Item xxx1
<ul class="dropdown-menu mega-dropdown-menu row dropdownMenuMop">
<div class="container topMenuColor">
<li class="col-sm-3">
<ul class="hideBullet">
<li class="dropdown-header hideBullet">Sprawy </li>
<li>pozycja 1</li>
<li>pozycja 2</li>
<li>pozycja 3</li>
<li>pozycja 4</li>
<li>pozycja 5</li>
<li class="dividerMop"></li>
<li class="dropdown-header hideBullet">pozycje 5</li>
<li>Bezpłatana imnformaja</li>
<li>dream</li>
<li>Callendar</li>
<li>Archiwum Mewspow</li>
</ul>
</li>
<li class="col-sm-3">
<ul class="hideBullet">
<li class="dropdown-header hideBullet">My life </li>
<li>Health</li>
<li>Bicycles</li>
<li>Cars</li>
<li>Education</li>
<li>Cash</li>
<li class="dividerMop"></li>
<li class="dropdown-header hideBullet">Fundation</li>
<li>xdcsdcsd cdscdscds</li>
<li>Magazine</li>
<li>Items</li>
<li>Items2</li>
</ul>
</li>
<li class="col-sm-3">
<ul class="hideBullet">
<li class="dropdown-header hideBullet">My life </li>
<li>Health</li>
<li>Bicycles</li>
<li>Cars</li>
<li>Education</li>
<li>Cash</li>
<li class="dividerMop"></li>
<li class="dropdown-header hideBullet">Fundation</li>
<li>xdcsdcsd cdscdscds</li>
<li>Magazine</li>
<li>Items</li>
<li>Items2</li>
</ul>
</li>
<li class="col-sm-3">
<ul>
<li class="dropdown-header">Accessories</li>
<li>Default Navbar</li>
<li>Lovely Fonts</li>
<li>Responsive Dropdown </li>
<li class="dividerMop"></li>
<li class="dropdown-header">Newsletter</li>
<form class="form" role="form">
<div class="form-group">
<label class="sr-only" for="email">Email address</label>
<input type="email" class="form-control" id="email" placeholder="Enter email"> </div>
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
</form>
<li class="dropdown-header">zamknij mnie2
<button type="button" class="close">×</button>
</li>
</ul>
</li>
</div>
</ul>
</li>
</ul>
</div>
<!-- /.nav-collapse -->
</div>
</nav>
I have a problem with the menu (NAVBAR).
I would like it to descend with scrolling the page down (stuck to the top of the browser).
The effect that I would like to get is here: https://www.gdynia.pl
Dla mieszkańców, aktualności, dla turystów, o Gdyni,
Does anyone know how to improve my code to get this effect?
Prview: http://serwer1356363.home.pl/pub/menu_fixed/
You can add to .navbar some other class with style like this: position: fixed; top:0; and replace position:relative with position:fixed;.
- Add this class only after you scroll down some pixels.
- If you not scrolled some pixels use remove or don't add class.
- Use Javascript or JQuery to detect how many user already scrolled pixels and also to add or remove element class.
I think everything is clear here. I just opened your site and used chrome dev tools to see applied effects. Just play with code and styles. After apply changes in real code.
You can look more here: set div position to fixed after scrolling 100px?

Initial Page Load Shows contents of both tabs

On initial load, the content from both tabs show on the webpage, once the tab is clicked for the first time they begin to work as expected.
Any ideas on why this is happening?
Here is my html
<div id="userFunctions" style="display: none;" >
<h2 id="welcome"></h2>
<button id="btnChangeUser" class="btn btn-primary" style="display: none;">Change User</button>
<br>
<hr>
<ul class="nav nav-tabs">
<li class="active"><a id="showSubs" data-toggle="tab" href="#subscriptionManagement">Subscription Portal</a></li>
<li><a id="showLocation" data-toggle="tab" href="#locationManagement">Location Management</a></li>
</ul>
<div class = tab-content>
<div id="subscriptionManagement" class="tab-pane fade in active">
<hr>
<section id="sendSubRequest">
<h4>Request Subscription</h4>
<div class="input-group">
<input type="text" id="subUserName" class="form-control "></input>
<span class="input-group-btn">
<button id="btnSubUser" class="btn btn-primary">Subscribe</button>
</span>
</div>
</section>
<br>
<section id="ReviewSubRequests">
<h4>Incoming Request(s)</h4>
<ul id='subscriptionsList'>
</ul>
</section>
</div>
<div id="locationManagement" class="tab-pane fade in active">
<hr>
<section id="cityDetails">
<section id="map">
</section>
<br>
<section>
<button id="btncheckInLocation" class="btn btn-primary">Check-In User location</button>
</section>
</section>
<section id="friendsList">
<h4>Subscribed Friends</h4>
<ul id='subscribedUsers'>
</ul>
</section>
</div>
</div>
</div>
Both your tabs (#subscriptionManagement and #locationManagement) have the active class, meaning they are both active by default. This class should be getting added on navigation, indicating that the content should be shown. You simply need to remove this class from the tab which you don't want to show on initial load:
Change:
<div id="locationManagement" class="tab-pane fade in active">
To:
<div id="locationManagement" class="tab-pane fade in">
Hope this helps! :)

collapse not working in siderbar

i added a data-toggle="collapse" to a link in nav side bar , and when link is clicked > should change to v ,when another tab is clicked it should change to >
but looks like collapse functionality is not working . in CSS i have the code to change icons , Can someone pint out the issue here
Thanks in advance
Below is the code snippet :-
<body>
<div class="container">
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<nav class="nav-sidebar">
<ul class="nav tabs">
<li class="active">tab1</li>
<li class=""> Tab2</li>
<li class=""> Tab3</li>
</ul>
</nav>
</div>
<!-- tab content -->
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 tab-content">
<div class="tab-pane active text-style collapse in" id="tab1">
<p> This is Tab1 content </p>
</div>
<div class="tab-pane text-style collapse" id="tab2">
<p> This is Tab2 content </p>
</div>
<div class="tab-pane text-style collapse" id="tab3">
<p> This is Tab3 content </p>
</div>
</div>
</div>
</body>
in css file
.nav-sidebar a:after {
font-family: 'Glyphicons Halflings';
content: "\e114";
float: right;
color: grey;
}
.nav-sidebar a.collapsed:after {
content: "\e080";
}
A couple of things here. You don't need to use the collapse with this as you are using bootstrap's tabs so you can scratch the collapse. So you don't need to put the data-target and data-toggle in the href's as bootstraps tabs will take care of this you just need to use data-toggle="tab" and it will toggle the tab by the href value. Then you can remove the collapse class from your tab panes as well. That being said bootstap will change the active class of the li when you click on the link so you can change your after content from there. So it will look like so:
Here is a fiddle showing you the changes Fiddle
Revised Html:
<ul class="nav tabs">
<li class="active"><a data-toggle="tab" href="#tab1">Tab 1</a></li>
<li><a data-toggle="tab" href="#tab2">Tab 2</a></li>
<li><a data-toggle="tab" href="#tab3">Tab 3</a></li>
</ul>
</nav>
</div>
<!-- tab content -->
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 tab-content">
<div class="tab-pane fade active in" id="tab1">
<p> This is Tab1 content </p>
</div>
<div class="tab-pane fade" id="tab2">
<p> This is Tab2 content </p>
</div>
<div class="tab-pane fade" id="tab3">
<p> This is Tab3 content </p>
</div>
</div>
</div>
Revised Css:
.nav-sidebar a:after{
content: "\e114";
font-family: 'Glyphicons Halflings';
color: grey;
float: right;
}
.nav-sidebar li.active a:after{
content: "\e080";
}

Button moves down the row

I got the following code. When I resize my browser window the button goes on the second row.
How can I keep the button on the same line?
index.html
<div class="row">
<div class="col-md-7 col-md-offset-3">
...
<section>
<div class="row">
<div class="col-sm-9">
<ul class="nav nav-pills text-center">
<li><a href>Description</a>
</li>
<li><a href>Specifications</a>
</li>
<li><a href>Reviews</a>
</li>
</ul>
</div>
<div class="col-sm-3">
<button ng-show="product.canPurchase" class="btn btn-primary pull-right buy-btn">Add to Cart</button>
</div>
</div>
</section>
...
</div>
</div>
custom.css
#media all and (max-width:480px) {
.buy-btn { width: 100%; display:block; }
}
before resizing
after resizing
and this is what I have on the minimum window width(fully collapsed)
you're using <div class="col-sm-9"> and <div class="col-sm-3">
this means that when the screen width is less than 768px it will break to col-12's
instead use <div class="col-xs-9"> and <div class="col-xs-3">

bootstrap - Hide navbar on small screen?

I have this structure:
<div class="container"><div class="row">
<div class="col-sm-10 col-xs-12">
<input id="searchBar">
</div>
<div class="col-sm-2">
<ul class="nav nav-pills nav-stacked">
<li><a>Item</a></li>
<li><a>Item</a></li>
<li><a>Item</a></li>
<li><a>Item</a></li>
</ul>
</div>
</div></div>
and I'm trying to hide the right navbar on mobile screens. I set it to xs-hidden, but it still shows up.
Is there a way to hide a navbar on xs screens?
Use .hidden-xs css class (not .xs-hidden).
<div class="container hidden-xs"><div class="row">
<div class="col-sm-10 col-xs-12">
<input id="searchBar">
</div>
<div class="col-sm-2">
<ul class="nav nav-pills nav-stacked hidden-xs">
<li><a>Item</a></li>
<li><a>Item</a></li>
<li><a>Item</a></li>
<li><a>Item</a></li>
</ul>
</div>
</div></div>
To help others and you reference the Bootstrap documentation "Responsive utilities"
As pointed out by Nicolapps you would use .hidden-xs
<div class="container">
<section class="row"
<div class="hidden-xs col-sm-10">
<p>content</p>
</div>
<div class="hidden-xs col-sm-2">
<p>content</p>
</div>
</section>
</div>
You can try something llike this stuff
you should set icon pointer events as none
.container {
position: relative
}
i {
position: absolute;
top: npx;
left: npx;
pointer-events: none;
}
select {
font-size: 0;
}