Bootstrap Progress Bar with Popovers - Timeline - css

I'm trying to create a timeline with plotted stages like a timeline using both the progress bar and popovers statically.
I'm getting close to what I want however I have 2 issues:
The popovers are stuck on the bottom line of the progress bar, I need to have the top popovers at the top of the progress bar and visa versa for the bottom.
There is the option of a top and bottom stage (e.g. building & pest, finance) to fall at the same day (e.g. day 10) so I need to be able to specifically set their position probably by a percentage of the total progress bar width.
I've added what I have done so far into JS fiddle.
Thanks
http://jsfiddle.net/elogicmedia/pGr2M/
My HTML
<div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" title="" style="width: 40%">Day 4
</div>
<div style="width: 100%;">
<ul id="horizontal-style">
<li class="mypopover" data-placement="top" data-content="Signed Contract" style="width: 0%; margin-bottom: 10px;"></li>
<li class="mypopover" data-placement="bottom" data-content="Building & Pest" style="width: 40%"></li>
<li class="mypopover" data-placement="top" data-content="Finance" style="width: 0%"></li>
<li class="mypopover" data-placement="bottom" data-content="Unconditional" style="width: 50%"></li>
<li class="mypopover" data-placement="top" data-content="Settlement" style="width: 5%"></li>
</ul>
</div>
</div>
MY CSS
body {
margin-top: 100px;
}
#horizontal-style {
display: table;
width: 100%;
}
#horizontal-style li {
display: table-cell;
}

You can that this way:
http://jsfiddle.net/VHXaK/
HTML:
<div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" title="" style="width: 40%">Day 4</div>
<div style="width: 100%;">
<ul id="horizontal-style">
<li class="mypopover" data-placement="top" data-content="Signed Contract" style="width: 0%; margin-bottom: 10px;"></li>
<li class="mypopover" data-placement="bottom" data-content="Building & Pest" style="width: 40%"></li>
<li class="mypopover" data-placement="top" data-content="Finance" style="width: 0%"></li>
<li class="mypopover" data-placement="bottom" data-content="Unconditional" style="width: 50%"></li>
<li class="mypopover" data-placement="top" data-content="Settlement" style="width: 5%"></li>
</ul>
</div>
</div>
CSS:
body {
margin-top: 100px;
}
.progress-bar-success {
position: relative;
}
#horizontal-style {
display: table;
width: 100%;
position:absolute;
height:20px;
}
#horizontal-style li {
display: table-cell;
}

Related

How to enable pagination on vertically aligned Angular Material tabs (mat-tabs)?

I arranged my angular material tabs vertically using CSS. Unfortunately, the pagination to navigate to the invisible tabs is not displayed
My container has a fixed height (max-height: 177px) so that only a certain number of tabs are visible. The pagination should appear when this fixed height is exceeded.
Here is my CSS / SCSS for the vertical tabs:
:host ::ng-deep {
.mat-tab-group {
flex-direction: row-reverse;
.mat-tab-nav-bar,
.mat-tab-header {
border: 0;
}
.mat-tab-header {
display: flex;
align-items: flex-end;
max-height: 177px;
right: 50px;
bottom: 50px;
z-index: 2147483647;
.mat-tab-labels {
flex-direction: column;
background: gray;
.mat-tab-label {
margin: 0;
padding: 20px;
cursor: pointer;
&:not(:last-child) {
border-bottom: 1px solid white;
}
&.mat-tab-label-active {
background-color: white !important;
width: 100%;
}
}
}
}
.mat-tab-body-wrapper {
width: 100%;
height: 100%;
display: table;
}
}
}
My template is structured like this:
<content>
<div class="main-wrapper i-wrapper">
<div class="header">
<div class="title">
<h4>Title</h4>
</div>
</div>
<mat-tab-group mat-align-tabs="end">
<div *ngFor="let item of items; let i = index">
<mat-tab label="{{i}}">
<div class="device-map-container">
<div class="device-map">
<img id="img_equipment" [src]="apiUrl + '/path/to/svg/' + asset | sanitize">
<a *ngFor="let data of SVGdata"
title="{{ data.title }}"
class="device-link">
</a>
<div class="wrapper">
<!-- another angular component -->
</div>
</div>
</div>
</mat-tab>
</div>
</mat-tab-group>
</div>
</content>
In dev tools the templates looks like this:
<mat-tab-group _ngcontent-nnd-c412="" mat-align-tabs="end" animationduration="0ms" class="mat-tab-group mat-primary" ng-reflect-animation-duration="0ms">
<mat-tab-header class="mat-tab-header" ng-reflect-selected-index="0" ng-reflect-disable-ripple="false" ng-reflect-disable-pagination="false">
<div aria-hidden="true" mat-ripple="" class="mat-ripple mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4 mat-tab-header-pagination-disabled" ng-reflect-disabled="true">
<div class="mat-tab-header-pagination-chevron"></div>
</div>
<div class="mat-tab-label-container">
<div role="tablist" class="mat-tab-list" style="transform: translateX(0px);">
<div class="mat-tab-labels">
<div role="tab" mattablabelwrapper="" mat-ripple="" cdkmonitorelementfocus="" class="mat-ripple mat-tab-label mat-focus-indicator mat-tab-label-active ng-star-inserted" id="mat-tab-label-0-0" ng-reflect-disabled="false" tabindex="0" aria-posinset="1" aria-setsize="2" aria-controls="mat-tab-content-0-0" aria-selected="true" aria-disabled="false">
<div class="mat-tab-label-content">
</div>
</div>
<div role="tab" mattablabelwrapper="" mat-ripple="" cdkmonitorelementfocus="" class="mat-ripple mat-tab-label mat-focus-indicator ng-star-inserted" id="mat-tab-label-0-1" ng-reflect-disabled="false" tabindex="-1" aria-posinset="2" aria-setsize="2" aria-controls="mat-tab-content-0-1" aria-selected="false" aria-disabled="false">
<div class="mat-tab-label-content">
</div>
</div>
</div>
<mat-ink-bar class="mat-ink-bar" style="visibility: visible; left: 0px; width: 50px;"></mat-ink-bar>
</div>
</div>
<div aria-hidden="true" mat-ripple="" class="mat-ripple mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4 mat-tab-header-pagination-disabled" ng-reflect-disabled="true">
<div class="mat-tab-header-pagination-chevron"></div>
</div>
</mat-tab-header>
<div class="mat-tab-body-wrapper">
<mat-tab-body role="tabpanel" class="mat-tab-body ng-tns-c380-10 mat-tab-body-active ng-star-inserted" id="mat-tab-content-0-0" ng-reflect-_content="[object Object]" ng-reflect-position="0" ng-reflect-origin="1" ng-reflect-animation-duration="0ms" aria-labelledby="mat-tab-label-0-0">
<div class="mat-tab-body-content ng-tns-c380-10 ng-trigger ng-trigger-translateTab" style="transform: none;">
<div _ngcontent-nnd-c412="" class="device-map-container ng-star-inserted" style="">
<div _ngcontent-nnd-c412="" class="device-map">
<img _ngcontent-nnd-c412="" id="img_equipment" alt="" src="data:image/svg+xml;base64,...">
</div>
</div>
</div>
</mat-tab-body>
<mat-tab-body role="tabpanel" class="mat-tab-body ng-tns-c380-11 ng-star-inserted" id="mat-tab-content-0-1" ng-reflect-_content="[object Object]" ng-reflect-position="1" ng-reflect-animation-duration="0ms" aria-labelledby="mat-tab-label-0-1">
<div class="mat-tab-body-content ng-tns-c380-11 ng-trigger ng-trigger-translateTab" style="transform: translate3d(100%, 0px, 0px); min-height: 1px;">
<!--container-->
</div>
</mat-tab-body>
</div>
</mat-tab-group>
Currently it looks like this (6 elements are visible. But there are more than 6 tabs in the container):

Bootstrap progress label not displayed entirely

I have a progress bar with a custom label inside:
<div id="progress" class="progress mb-1" style="height: 20px;">
<div class="progress-bar" role="progressbar" style="width: 5.0%" aria-valuenow="5.0" aria-valuemin="0" aria-valuemax="100">1/20</div>
</div>
It works like a charm. However, the label is not displayed entirely on the left for small screens:
I've tried to get around this in a couple of ways (hardcoding the width of the bar to 2 for 1, playing around with colours) but I wonder if this is a more elegant solution for this?
You can add a second div containing the label, something like this :
<div id="progress" class="progress mb-1">
<div class="progress-label">1/20</div>
<div class="progress-bar" role="progressbar" style="width: 5.0%" aria-valuenow="5.0" aria-valuemin="0" aria-valuemax="100">1/20</div>
</div>
With some style :
.progress {
position: relative;
}
.progress-bar {
overflow: hidden;
z-index: 2;
}
.progress-label {
color: #0275D8;
position: absolute;
left: 0;
height: 100%;
top: 0;
z-index: 1;
}
Preview :
Fixed my issue with the following code:
<div id="progress" class="progress mb-1" style="height: 20px;">
<div class="progress-bar" role="progressbar" style="width: 5.0%; min-width:100px;" aria-valuenow="5.0" aria-valuemin="0" aria-valuemax="100">1/20</div>
</div>

Having multiple progress bars in Bootstrap with left label pushing to the right

I want to have multiple progress bars using Bootstrap 4 with labels or at least text on its outer left. So far this works, but with multiple bars, it looks like an inverted stair.
What I currently have as code is the following:
<div class="container">
<p class="progress-label">
C#
</p>
<div class="progress" id="prog1">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
<span class="sr-only">20% Complete</span>
</div>
</div>
</div>
<div class="container">
<p class="progress-label">
C#
</p>
<div class="progress" id="prog1">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
<span class="sr-only">20% Complete</span>
</div>
</div>
</div>
with CSS
.progress-label {
float: left;
margin-right: 1em;
}
taken from How to put a label side by a progress bar with bootstrap?
So far I am not sure what I can do to make it work properly, with both bars aligned.
Here's a fiddle:
Try to wrap each progress bar in a div with class called 'progressHolder'. Then in CSS just add 'overflow:hidden' since you have used 'float:left' in 'progress-label.'
HTML Code:
<div class="container">
<div class="progressHolder">
<p class="progress-label">
C#
</p>
<div class="progress" id="prog1">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100" style="width: 40%">
<span class="sr-only">20% Complete</span>
</div>
</div>
</div>
</div>
<div class="container">
<div class="progressHolder">
<p class="progress-label">
C#
</p>
<div class="progress" id="prog2">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100" style="width: 40%">
<span class="sr-only">20% Complete</span>
</div>
</div>
</div>
</div>
CSS Code:
.progressHolder {
overflow: hidden;
}
.progress-label {
float: left;
margin: -5px 15px 15px 0;
}
Demo:
https://codepen.io/Bibeva/pen/RwNMjNB
Set the .container to float: left as well
I've added a calc to margin-top to center the text with the progress bar
.container {
float:left;
}
.progress {
margin-top: 1rem;
}
.progress-label {
float: left;
margin-top: calc(1rem - 4px);
margin-right: 1em;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="container">
<p class="progress-label">C#</p>
<div class="progress" id="prog1">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
<span class="sr-only">20% Complete</span>
</div>
</div>
</div>
<div class="container">
<p class="progress-label">C#</p>
<div class="progress" id="prog2">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
<span class="sr-only">20% Complete</span>
</div>
</div>
</div>
some points you should take care of:
container class is not recommeded to use with inner elements, it is for the layout, refer to this link: https://getbootstrap.com/docs/4.4/layout/overview/#containers
ID should be unique, can't be used on multiple elements. Use classes for multi purpose.
my suggestion is to use those css styles to achieve what you need.
.container{
margin: 10px;
}
.progress-label{
padding: 0px 10px;
float: left;
margin-bottom: 0px;
top: -4px;
position: relative;
}
Use <label> instead of <p> in progress-label

Bootstrap navbar appears differently in Firefox and Chrome due to browser rendering inconsistencies

The screenshot below is my bootstrap navbar which works nicely (pills disappear one by one as per spec). However when scaled down to various screen sizes, the navbar is no longer in-line and becomes staggered.
The issue is worse in Chrome than in Firefox because the left hand section of the navbar does not sit at the top of the screen.
If I can get Chrome to look like the Firefox screenshot, this will help me fix the remaining issues.
Can anyone suggest which browser rendering inconsistency would explain why on the Chrome version, the left hand portion of the navbar does not sit flush with the top of the screen?
Top is Chrome, bottom is FireFox.
<header>
<div class="vr-nav-container" data-ng-controller="navBarController">
<div>
<div class="col vr-nav-col1">
<div class="nowrap">
<nav class='navbar navbar-default navbar-static-top no-padding" role="navigation"'>
<a class='navbar-brand' href='/Default'>
<img height="30" class="logo" alt="Flatty" src="/Assets/images/logo-small-rocket-lg.png" />
<img height="30" id="xs-toggler" class="logo-xs" alt="Flatty" src="/Assets/images/logo_xs.png" />
</a>
</nav>
</div>
</div>
<div class="col vr-nav-col2 fill center">
<div class="nowrap">
<nav class='navbar navbar-default navbar-static-top " role="navigation"'>
<div class="tabbable ">
<ul class="nav nav-pills contrast-background">
<li data-ng-repeat="item in NavBarViewModel">
<a href="{{item.Path}}"><i class="{{item.Icon}}"></i>
{{item.Title}}
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="col vr-nav-col3">
<div class="nowrap">
<nav class='navbar navbar-default navbar-static-top" role="navigation"'>
<ul class='nav'>
<li ng-controller="awardBoxController" class='dropdown medium only-icon widget'>
<a class='dropdown-toggle' data-toggle='dropdown' href='#'>
<i class='icon-trophy'></i>
<div class='label'>{{AwardSummary.TotalPoints}}</div>
</a>
<ul class='dropdown-menu'>
<li>
<div class="box-content box-statistic">
<h3 class="title text-error">{{AwardSummary.Level}}</h3>
<small>{{AwardSummary.TotalPoints}} points</small>
<div class="text-banana icon-trophy align-right"></div>
</div>
</li>
<li><a href="/#/Awards/My-Points/">
<div class='points-history box-content widget-body'>
<div class='pull-left icon'>
<i class='icon- text-banana'></i>
</div>
<div class='pull-left text'>
<span><strong>Point History</strong> <span class="see-all">- see all</span></span>
<small class='text-muted'>{{award.AcheivedDate}}</small>
</div>
</div>
</a></li>
<li ng-repeat="award in AwardSummary.Awards">
<a href='#'>
<div class=' box-content widget-body'>
<div class='pull-left icon'>
<i class='icon-{{award.Icon}} text-success'></i>
</div>
<div class='pull-left text'>
{{award.Name}}
<span class="text-muted">+{{award.Points}}</span>
<small class='text-muted'>{{award.AcheviedDate| fromNow}}</small>
</div>
</div>
</a>
</li>
<li class='divider'></li>
<li class='widget-footer'>
<a href='/#/Awards/High-Scores/'>High Scores</a>
</li>
</ul>
</li>
<li class='dropdown medium user-menu'>
<a class='dropdown-toggle' data-toggle='dropdown' href='#'>
<img width="23" height="23" src="/Assets/images/avatar.jpg" />
<span class='user-name'>
<asp:Literal ID="UserFirstNameLiteral" runat="server" meta:resourcekey="UserFirstNameLiteral">FirstName LastName</asp:Literal></span>
<b class='caret'></b>
</a>
<ul class='dropdown-menu'>
<li>
<a href='/UserAccount/UserProfile'>
<i class='icon-user'></i>
<%= this.GetGlobalResourceObject("MasterPage","Profile") %>
</a>
</li>
<li>
<a ng-if="ShowSettings" href='/Settings/Dashboard'>
<i class='icon-cog'></i>
<%= this.GetGlobalResourceObject("Resources","Settings") %>
</a>
</li>
<li>
<a ng-if="ShowSettings" href='http://todo.help.vr.zendeskurl.com'>
<i class='icon-bullhorn'></i>
<%= this.GetGlobalResourceObject("MasterPage","GetHelp") %>
</a>
</li>
<li class='divider'></li>
<li>
<form runat="server">
<asp:LinkButton ID="SignOutLinkButton" runat="server" OnClick="SignOutLinkButton_Click" meta:resourcekey="SignOutLinkButton">
<i class='icon-signout'></i> <%= this.GetGlobalResourceObject("Resources","SignOut") %>
</asp:LinkButton>
</form>
</li>
</ul>
</li>
</ul>
<div class='navbar-form navbar-right hidden-xs'>
<button class='btn btn-link dropdown-toggle' style="top: 4px;" name='button' data-toggle="dropdown" type='submit'><i class="icon-search"></i><span class="caret"></span></button>
<ul class="dropdown-menu">
<li>
<a category="" class="searchoption" href="#"><%= this.GetGlobalResourceObject("MasterPage","Everything") %></a>
</li>
<li class="divider"></li>
<li>
<a category="Deals" class="searchoption" href="#"><%= this.GetGlobalResourceObject("Resources","Deals") %></a>
</li>
<li>
<a category="Contacts" class="searchoption" href="#"><%= this.GetGlobalResourceObject("Resources","Contacts") %></a>
</li>
<li>
<a category="Accounts" class="searchoption" href="#"><%= this.GetGlobalResourceObject("Resources","Accounts") %></a>
</li>
<li>
<a category="Tasks" class="searchoption" href="#"><%= this.GetGlobalResourceObject("Resources","Tasks") %></a>
</li>
</ul>
<div class='form-group'>
<input value="" id="searchBox" class="form-control" placeholder='<%= this.GetGlobalResourceObject("Resources","Search") %>...' autocomplete="off" id="q_header" name="q" type="text" />
</div>
</div>
</nav>
</div>
</div>
</div>
</div>
</header>
CSS
I am using the default bootstrap 3.0 CSS and have a seperate CSS file overriding some default CSS and adding my own
I had to do this because the pills section has to be in its own div in the centre column in order to work (disappear one by one and 'stack' as width decreases) and fill all the width between the left and right cols in the navbar.
.navbar-collapse:after {
clear: none;
}
.sorting, .sorting_asc, .sorting_desc {
background : none;
}
.top-buffer {
margin-top: 20px !important;
}
.removeclass{
font-size: 1.5em;
vertical-align: middle !important;
}
.removeclass:hover{
text-decoration: none;
}
.vr-navigation {
float: left;
width: 100%;
}
.rightnav {
float: right;
width: 285px;
margin-left: -160px;
}
.leftnav {
margin-right: 160px;
padding:0 10px;
width:auto;
height: 40px;
}
.nav-pills {
height: 40px;
}
.hidden-xs {
display: inline-block !important;
}
#media (max-width: 767px) {
.hidden-xs {
display: none!important;
}
}
.current {
font-weight: bold;
}
.nav-pills li a {
color: white;
}
.vr-nav-container
{
display: table;
}
.vr-nav-container > div
{
display: table-row;
}
.vr-nav-container > div > div
{
display: table-cell;
}
.vr-nav-container > div > div
{
padding: 0em;
}
.vr-nav-container .nowrap
{
white-space: nowrap;
}
.vr-nav-container .fill
{
margin: 0 auto;
}
.vr-nav-container .center
{
text-align: center;
}
.vr-nav-col1
{
/*background: red;*/
width: 5%;
min-width: 50px;
white-space: nowrap;
}
.vr-nav-col2
{
width: 50%;
margin: 0 auto;
/*background: yellow;*/
}
.vr-nav-col3
{
/*background: green;*/
width: 40%;
/*min-width: 260px;*/
}
.no-padding
{
padding-left: 0px !important;
padding-right: 0px !important;
}
.main-nav-closed #main-nav .navigation > .nav > li:hover > a.toggler-flyout > span
{
display: none;
}
/*.main-nav-closed #main-nav .navigation > .nav > li:hover > a.toggler-flyout > i
{
content: "\f061";
}*/

Twitter Bootstrap: Center Text on Progress Bar

I've been using Twitter's bootstrap and I would like the text on the progress bar to be centered on the on bar regardless of value.
The below link is what I have now. I would like all text to be aligned with the bottom most bar.
Screenshot:
I've tried my best with pure CSS and I'm trying to avoid using JS if possible but I'm willing to accept it if it's the cleanest way to do it.
<div class="progress">
<div class="bar" style="width: 86%">517/600</div>
</div>
Bootstrap 5: (Same as v4x)
<div class="progress position-relative">
<div class="progress-bar" role="progressbar" style="width: 60%" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100"></div>
<small class="justify-content-center d-flex position-absolute w-100">60% complete</small>
</div>
Bootstrap 4 with utility classes: (Thanks to MaPePeR for the addition)
<div class="progress position-relative">
<div class="progress-bar" role="progressbar" style="width: 60%" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100"></div>
<small class="justify-content-center d-flex position-absolute w-100">60% complete</small>
</div>
Bootstrap 3:
Bootstrap now supports text within a span element in the Progress bar. HTML as provided in Bootstrap's example. (Notice the class sr-onlyis removed)
HTML:
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
<span>60% Complete</span>
</div>
</div>
... It does however only center the text according to the bar itself, so we need a little bit of custom CSS.
Paste this in another stylesheet/below where you load bootstrap's css:
CSS:
/**
* Progress bars with centered text
*/
.progress {
position: relative;
}
.progress span {
position: absolute;
display: block;
width: 100%;
color: black;
}
JsBin file: http://jsbin.com/IBOwEPog/1/edit
Bootstrap 2:
Paste this in another stylesheet/below where you load Bootstrap's CSS:
/**
* Progress bars with centered text
*/
.progress {
position: relative;
}
.progress .bar {
z-index: 1;
position: absolute;
}
.progress span {
position: absolute;
top: 0;
z-index: 2;
color: black; /* Change according to needs */
text-align: center;
width: 100%;
}
Then add text to a progress bar by adding a span element outside .bar:
<div class="progress">
<div class="bar" style="width: 50%"></div>
<span>Add your text here</span>
</div>
JsBin: http://jsbin.com/apufux/2/edit
Bootstrap 3 answer, as shown in bootstrap example
<div class="progress text-center">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
<span>60% Complete</span>
</div>
<span>40% Left</span>
</div>

Resources