i'm working on a leaflet map and i want to add a legend on it by using a modal to do that.
In my modal i want to use a :
<ul><li>
and each ligne of my ul can be an horizontal line with a text or an icon with a text.
exemple :
-----(red) : Polyline of users
-----(green) : Polyline of the race
(icon) : marker of users ....
I don't know how to draw a red line in html/css to do something like that.
I have tried the <hr> but it's always take all the line.
thanks for your help.
I include the code of my modal :
<div id="infoModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Informations</h4>
</div>
<div class="modal-body">
<h2>Legende : </h2>
<ul class="list-group">
<li class="list-group-item">
<div class="col-md-4">
<hr width="25%" size="10">
</div>
<div class ="col-md-8">
TEST
</div>
</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Example (From Comment Section)
You could use flexbox and a pseudo-element.
.list-group-item {} .list-group-item div {
display: flex;
align-items: center;
}
.list-group-item div::before {
content: '';
flex: 1;
height: 5px;
background: red;
margin-right: 1em;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="modal-body">
<h2>Legende : </h2>
<ul class="list-group">
<li class="list-group-item">
<div class="col-sm-12">
<img src="http://lorempixel.com/image_output/abstract-q-c-25-25-2.jpg" alt="">
</div>
</li>
</ul>
</div>
Try this:
.my-divider {
position: relative;
left: 100px;
}
.my-divider::before {
content: "";
position: absolute;
top: 50%;
left: -100px;
width: 100px;
border-bottom: 1px solid red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-md-offset-4 col-md-8 my-divider">TEST</div>
</div>
</li>
</ul>
Values are a bit arbitrary so change those to suit.
Related
I have a simple bootstrap 4 carousel, I would like a carousel caption to appear on top instead of bottom something like this below.
update: HERE IS JSFIDLE WITH FULL CODE
carousel demo
Here is what I have tried so far
HTML
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="pull-left">My Gallery Title</div>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div id="demo" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1"></li>
<li data-target="#demo" data-slide-to="2"></li>
</ul>
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<div class="carousel-caption">
<h3>Heading 1</h3>
</div>
<img src="https://placeimg.com/600/400/nature/1" alt="Los Angeles">
</div>
<div class="carousel-item">
<div class="carousel-caption">
<h3>Heading 2</h3>
</div>
<img src="https://placeimg.com/600/400/nature/2" alt="Chicago">
</div>
<div class="carousel-item">
<div class="carousel-caption">
<h3>Heading 3</h3>
</div>
<img src="https://placeimg.com/600/400/nature/3" alt="New York">
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>
<div class="modal-footer">
<button class="btn-sm close" type="button" data-dismiss="modal">Close</button>
<!--end modal-footer-->
</div>
<!--end modal-content-->
</div>
<!--end modal-dialoge-->
</div>
<!--end myModal-->>
</div>
CSS
.carousel-caption {
position: absolute;
right: 15%;
top: -42px;
left: 15%;
z-index: 999999999;
padding-top: 20px;
padding-bottom: 20px;
color: #fff;
text-align: center;
}
Unfortunately, with this solution, my carousel caption disappear.
What do I need to do to get what I want?
change css of .carousel-caption
.carousel-item .carousel-caption {
position: static;
padding-top: 20px;
padding-bottom: 20px;
text-align: center;
}
working fiddle here
Change the value of top to 0. The carousel caption will move to top of your carousel exactly opposite to carousel indicators.
Try using the inspect element and check the position of your concern element.
Use property relative in div with class ".carousel-item"
.carousel-item{
position:relative;
}
.carousel-caption {
position: absolute;
top: 0;
left: 0;
width:100%;
text-align:center;
z-index: 999999999;
padding-top: 5px;
color: #fff;
}
Full working example in codepen:
https://codepen.io/anon/pen/bJygvj
Here I am trying to draw a horizontal line between the buttons. I have tried in many ways but I can't get it. I think I need to do some magics in CSS but I am new to HTML and CSS That's why I can't find the way to make it work.
I want:
I got this:
.divided {
display: flex;
align-items: center;
}
.divider {
flex-grow: 1;
border-bottom: 1px solid black;
margin: 5px
}
<div class="col-sm-9" style="padding-left:0px;padding-right:0px">
<div class="col-sm-12 row">
<div class="container" style="padding-left:0px;padding-right:0px">
<div class="row divided">
<div class="col-sm-3">
<button mat-mini-fab>1</button>
<span style="padding-left:15px">Login</span>
</div>
<span class="divider"></span>
<div class="col-sm-3">
<button mat-mini-fab>2</button>
<span style="padding-left:15px">Address</span>
</div>
<span class="divider"></span>
<div class="col-sm-3">
<button mat-mini-fab>3</button>
<span style="padding-left:15px">Mycart</span>
</div>
<span class="divider"></span>
<div class="col-sm-3">
<button mat-mini-fab>4</button>
<span style="padding-left:15px">Payment</span>
</div>
</div>
</div>
</div>
</div>
Can anyone help me to solve this ?
Update:
Use pseudo :after to <div class="col-sm-3 divder">
Instead using <span class="divider"></span> (-- remove it)
.divder:after{
content: '';
width: 71px;
height: 2px;
top: 15px;
background: black;
position: absolute;
right: -12px;
}
<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>
<div class="container">
<div class="row">
<div class="col-sm-9" style="padding-left:0px;padding-right:0px">
<div class="col-sm-12 row">
<div class="container" style="padding-left:0px;padding-right:0px">
<div class="row divided">
<div class="col-sm-3 divder">
<button mat-mini-fab>1</button>
<span style="padding-left:15px">Login</span>
</div>
<div class="col-sm-3 divder">
<button mat-mini-fab>2</button>
<span style="padding-left:15px">Address</span>
</div>
<div class="col-sm-3 divder">
<button mat-mini-fab>3</button>
<span style="padding-left:15px">Mycart</span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>4</button>
<span style="padding-left:15px">Payment</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I think you're trying to do the same as you would do when using a stepper
https://material.angular.io/components/stepper/overview
Using import {MatStepperModule} from '#angular/material/stepper';
and the correct elements will do the trick
You can use :after psuedo class
.divider:after {
height:1px;
width:40px;
content:'';
background: red;
position:absolute;
right:0px;
top:15px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="col-sm-12" style="padding-left:0px;padding-right:0px">
<div class="col-sm-12 row">
<div class="container" style="padding-left:0px;padding-right:0px">
<div class="row divided">
<div class="col-sm-3">
<button mat-mini-fab>1</button>
<span style="padding-left:0px">Login</span>
<span class="divider"></span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>2</button>
<span style="padding-left:0px">Address</span>
<span class="divider"></span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>3</button>
<span style="padding-left:0px">Mycart</span>
<span class="divider"></span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>4</button>
<span style="padding-left:0px">Payment</span>
</div>
</div>
</div>
</div>
</div>
Following code adds equally sized lines between menu items as long there is enough space.
/* all direct children of menu and item are laid out in a single row as long as there is enough space */
.menu,
.item {
display: flex;
flex-flow: row wrap;
}
/* all menu items can grow except the last one */
.item:not(:last-child) {
flex-grow: 1;
}
/* a horizontal line is appended to all items if space is available (except the last item) */
.item:not(:last-child):after {
content: '';
border-bottom: 1px solid #000;
height: 50%; /* centers line vertically */
flex-grow: 1;
margin-right: 10px;
}
/* not relevant for menu (typography and resets) */
button,
span {
font-family: Times;
font-size: 16px;
padding: 0;
border: 0;
margin-right: 10px;
}
/* not relevant for menu (rounded buttons) */
button {
background-color: #ddd;
border-radius: 50%;
height: 20px;
width: 20px;
}
<div class="menu">
<div class="item">
<button>1</button>
<span>Login</span>
</div>
<div class="item">
<button>2</button>
<span>Address</span>
</div>
<div class="item">
<button>3</button>
<span>Mycart</span>
</div>
<div class="item">
<button>4</button>
<span>Payment</span>
</div>
</div>
A
I am making a lightbox - carousel - modal page with Bootstrap 3. So far, all is going very well, except for one thing:
When the carousel starts, it always starts at the very first image of the page, not the image that I click on.
In other words: if I click on image 1 then image 1 is opened, if I click on image 2, then image 1 is opened, if I click on image 3, then image 1 is opened.
After that, the carousel works like it should, but what I want is, that when I click on image 2, that image 2opens, and if I click on image 3, that image 3 opens.
Some code:
<ul class="cropped-images">
<li class="la active"><a data-content="No 1" href="#lightbox" data-toggle="modal" data-slide-to="0"><img src="images/thumbs/1.jpg" alt="No 1"></a></li>
<li class="la"><a data-content="No 2" href="#lightbox" data-toggle="modal" data-slide-to="1"><img src="images/thumbs/2.jpg" alt="No 2"></a></li>
<li class="la"> etc... </ul>
<div id="lightbox" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">TITLE</h4>
</div>
<div id="carousel-example-generic" class="carousel slide">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="images/large/1.jpg" alt="...">
<div class="carousel-caption">One Image</div>
</div>
<div class="item">
<img src="images/large/2.jpg" alt="...">
<div class="carousel-caption">Another Image</div>
</div>
... etc...
<!-- Controls -->
controls code
</div>
</div>
</div>
</div>
Any suggestions please?
You can use Bootstrap Carousel to create your own custom lightbox, something as shown that I've tried to show in the snippet below, please have a look:
$('.content-holder .thumbnail').each(function(i) {
var item = $('<div class="item"></div>');
var itemDiv = $(this).parents('div');
var title = $(this).parent('a').attr("title");
item.attr("title", title);
$(itemDiv.html()).appendTo(item);
item.appendTo('.carousel-inner');
if (i === 0) { // set first item active
item.addClass('active');
}
});
/* activate the carousel */
$('#modalCarousel').carousel({interval: false});
/* change modal title when slide changes */
$('#modalCarousel').on('slid.bs.carousel', function () {
$('.modal-title').html($(this).find('.active').attr("title"));
});
/* when clicking a thumbnail */
$('.row .thumbnail').click(function(){
var idx = $(this).parents('div').index();
var id = parseInt(idx);
$('#myModal').modal('show'); // show the modal
$('#modalCarousel').carousel(id); // slide carousel to selected
});
.thumbnail {
height: 100px;
margin: 6px;
}
.thumbnail {
margin-bottom: 6px;
}
.carousel-control.left {
background-image: none;
position: absolute;
top: 50%;
left: 0;
width: 25px;
height: 100%;
transform: translateY(-50%);
}
.carousel-control.right {
background-image: none;
position: absolute;
top: 50%;
right: 0;
width: 25px;
height: 100%;
transform: translateY(-50%);
}
.item .thumbnail {
margin: 0 auto;
}
body {
margin: 20px !important;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="content-holder">
<div class="container">
<div class="row">
<div class="col-lg-2 col-sm-3 col-xs-6">
<a href="#">
<img class="thumbnail img-responsive" src="http://placehold.it/200x200" alt="" title="">
</a>
</div>
<div class="col-lg-2 col-sm-3 col-xs-6">
<a href="#">
<img class="thumbnail img-responsive" src="http://placehold.it/300x300" alt="" title="">
</a>
</div>
</div>
</div>
</div>
<!-- lightbox modal -->
<div class="modal" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">Lightbox</h3>
</div>
<div class="modal-body">
<div id="modalCarousel" class="carousel">
<div class="carousel-inner"></div>
<a class="carousel-control left" href="#modalCarousel" data-slide="prev">
<i class="glyphicon glyphicon-chevron-left"></i>
</a>
<a class="carousel-control right" href="#modalCarousel" data-slide="next">
<i class="glyphicon glyphicon-chevron-right"></i>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- end lightbox modal -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
Hope this helps!
Try to something like this.
Just replace below line in your html code
<div id="carousel-example-generic" class="carousel slide">
to
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
I have a modal that will house an image gallery. When the first modal is opened, there are thumbnails, and when a thumbnail image is clicked, a secondary modal will open on top of the first modal, which will have the larger images in a carousel (of course whichever thumbnail is clicked, that corresponding large image will open in the second modal's carousel position).
Right now, when I click either thumbnail, the second modal opens up, but it shows both of the thumbnails, instead of the larger image of the corresponding thumbnail. Very weird, I seem to have it right by looking at the code, but not sure why it's not working.
Here is the HTML:
<!-- kitchens modal -->
<div class="modal kitchens-modal fade" id="kitchens-modal" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<!-- modal header -->
<div class="modal-header">
<h1>KITCHENS</h1>
<h3>Your dream kitchen is so close...</h3>
</div>
<!-- end modal header -->
<!-- modal body -->
<div class="modal-body">
<div class="row">
<div class="col-lg-2 col-sm-3 col-xs-6">
<a href="#">
<img class="thumbnail img-responsive" src="./assets/img/kitchens/kitchen.jpg" alt="Kitchen" title="Kitchen">
</a>
</div>
<div class="col-lg-2 col-sm-3 col-xs-6">
<a href="#">
<img class="thumbnail img-responsive" src="./assets/img/kitchens/kitchen1.jpg" alt="Kitchen two" title="Kitchen two">
</a>
</div>
</div>
</div>
<!-- end modal body -->
<!-- modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
<!--end modal footer -->
</div>
</div>
</div>
<!-- end kitchens modal -->
<!-- inner kitchen gallery modal -->
<div class="modal" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title"></h3>
</div>
<div class="modal-body">
<div id="modalCarousel" class="carousel">
<div class="carousel-inner">
</div>
<a class="carousel-control left" href="#modaCarousel" data-slide="prev">
<i class="glyphicon glyphicon-chevron-left"></i>
</a>
<a class="carousel-control right" href="#modalCarousel" data-slide="next">
<i class="glyphicon glyphicon-chevron-right"></i>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- end inner kitchen gallery modal -->
And the CSS:
.thumbnail {
height: 100px;
margin: 6px;
}
.thumbnail {
margin-bottom: 6px;
}
.carousel-control.left,
.carousel-control.right {
background-image: none;
margin-top: 10%;
width: 5%;
}
And lastly, the JS:
$('.row .thumbnail').on('load', function() {
}).each(function(i) {
if(this.complete) {
var item = $('<div class="item"></div>');
var itemDiv = $(this).parents('div');
var title = $(this).parent('a').attr("title");
item.attr("title", title);
$(itemDiv.html()).appendTo(item);
item.appendTo('.carousel-inner');
if (i === 0) { // set first item active
item.addClass('active');
}
}
});
/* activate the carousel */
$('#modalCarousel').carousel({interval: false});
/* change modal title when slide changes */
$('#modalCarousel').on('slid.bs.carousel', function () {
$('.modal-title').html($(this).find('.active').attr("title"));
});
/* when clicking a thumbnail */
$('.row .thumbnail').click(function(){
var idx = $(this).parents('div').index();
var id = parseInt(idx);
$('#myModal').modal('show'); // show the modal
$('#modalCarousel').carousel(id); // slide carousel to selected
});
I got this from a modal gallery I found online, and modified it a bit, but it just won't work! When I open the modal, and click on the thumbnail, the second modal just has all the thumbnails there, instead of the one image.
You can try something like:
$('.kitchens-modal .thumbnail').each(function(i) {
var item = $('<div class="item"></div>');
var itemDiv = $(this).parents('div');
var title = $(this).parent('a').attr("title");
item.attr("title", title);
$(itemDiv.html()).appendTo(item);
item.appendTo('.carousel-inner');
if (i === 0) { // set first item active
item.addClass('active');
}
});
/* activate the carousel */
$('#modalCarousel').carousel({interval: false});
/* change modal title when slide changes */
$('#modalCarousel').on('slid.bs.carousel', function () {
$('.modal-title').html($(this).find('.active').attr("title"));
});
/* when clicking a thumbnail */
$('.row .thumbnail').click(function(){
var idx = $(this).parents('div').index();
var id = parseInt(idx);
$('#myModal').modal('show'); // show the modal
$('#modalCarousel').carousel(id); // slide carousel to selected
});
.thumbnail {
height: 100px;
margin: 6px;
}
.thumbnail {
margin-bottom: 6px;
}
.carousel-control.left {
background-image: none;
position: absolute;
top: 50%;
left: 0;
width: 25px;
height: 100%;
transform: translateY(-50%);
}
.carousel-control.right {
background-image: none;
position: absolute;
top: 50%;
right: 0;
width: 25px;
height: 100%;
transform: translateY(-50%);
}
.item .thumbnail {
margin: 0 auto;
}
body {
margin: 20px !important;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="btn btn-primary" data-target="#kitchens-modal" data-toggle="modal">Open Kitchen Modal</div>
<!-- kitchens modal -->
<div class="modal kitchens-modal fade" id="kitchens-modal" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<!-- modal header -->
<div class="modal-header">
<h1>KITCHENS</h1>
<h3>Your dream kitchen is so close...</h3>
</div>
<!-- end modal header -->
<!-- modal body -->
<div class="modal-body">
<div class="row">
<div class="col-lg-2 col-sm-3 col-xs-6">
<a href="#">
<img class="thumbnail img-responsive" src="http://placehold.it/200x200" alt="Kitchen" title="Kitchen">
</a>
</div>
<div class="col-lg-2 col-sm-3 col-xs-6">
<a href="#">
<img class="thumbnail img-responsive" src="http://placehold.it/300x300" alt="Kitchen two" title="Kitchen two">
</a>
</div>
</div>
</div>
<!-- end modal body -->
<!-- modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
<!--end modal footer -->
</div>
</div>
</div>
<!-- end kitchens modal -->
<!-- inner kitchen gallery modal -->
<div class="modal" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title"></h3>
</div>
<div class="modal-body">
<div id="modalCarousel" class="carousel">
<div class="carousel-inner">
</div>
<a class="carousel-control left" href="#modalCarousel" data-slide="prev">
<i class="glyphicon glyphicon-chevron-left"></i>
</a>
<a class="carousel-control right" href="#modalCarousel" data-slide="next">
<i class="glyphicon glyphicon-chevron-right"></i>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- end inner kitchen gallery modal -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
Hope this helps!
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>