How to prevent that vertical pills overlap with tab contents? - html

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>

Related

Bootstrap 4: Footer not at bottom

I know this question was probably asked some hundred times, but sadly no answer that I found in here really helped me.
I tried these answers for example:
Bootstrap footer not at bottom
Flushing footer to bottom of the page, twitter bootstrap
Height not 100% on Container Fluid even though html and body are
But I still have the problem that when my page content is to "small" and doesn't fill out the whole height of the body/page container the footer just floats somewhere above the end of the browser window.
This is the code for my footer:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
<footer class="d-flex justify-content-center">
<div class="d-flex justify-content-between col-md-8 col-md-offset-2 mb-3 mt-5">
<div class="align-left">
<a class="font-weight-bold small kf-blue kf-links" href="#">Link1</a> |
<a class="font-weight-bold small kf-blue kf-links" href="/">Link2</a> |
<a class="font-weight-bold small kf-blue kf-links" href="/">Link3</a>
</div>
<div class="align-right small">
Crafted with Love by <a class="font-weight-bold kf-blue kf-links" href="#" target="_blank">Me</a>
</div>
</div>
</footer>
I'm using Bootstrap 4.1 and Chrome, here's also a codepen to my site:
https://codepen.io/anon/pen/oMZVxq
Note: you have to use the sidebar view in codepen to actually see that the footer is not at the bottom, as the view size in codepen is so small that it looks correctly.
You can use built-in bootstrap class to achieve this.
What you need is the container to be a column flex container . class to use are : d-flex flex-column
To set the container to height:100% you can apply the class h-100to html, body and the container or add to the container style height:100vh;
For the footer, a margin-top:auto will do, the class to use is : mt-auto;
example below to run in full page mode
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<html class="h-100">
<body class="h-100">
<!-- Page Container -->
<div id="page-container" class="container-fluid pr-0 pl-0 h-100 d-flex flex-column">
<!-- Header -->
<nav class="navbar navbar-expand-lg navbar-light bg-light pt-3 pb-3 d-flex justify-content-center">
<div class="col-md-8 col-lg-8 col-sm-12 col-xs-12 d-flex justify-content-between">
<div class="d-flex justify-content-start align-items-center">
<a href="/" class="kf-links">
<span class="h5">
<i class="fas fa-paper-plane"></i>
<span class="h4 font-weight-bold kf-dark">
MyPage
</span>
</span>
</a>
</div>
<!-- Main Header Navigation -->
<div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
<ul class="navbar-nav">
<li class="nav-item">
Link1
</li>
<li class="nav-item">
Link2
</li>
<li class="nav-item">
Link3
</li>
</ul>
</div>
<!-- END Main Header Navigation -->
</div>
</nav>
<!-- END Header -->
<!-- Main Container -->
<div style="background:#5c90d2">
<div class="col-md-12 text-center pt-5 pb-5">
<div class="pt-5 pb-5">
<h1>
<span class="main-text">
Login
</span>
</h1>
<p class="lead"><span class="main-text">
Login Now!
</span></p>
</div>
</div>
</div>
<!-- Content -->
<div class="d-flex justify-content-center fadeIn">
<div class="col-md-8 col-xs-12">
<div class="d-flex justify-content-center">
<div class="col-md-6 pt-5 pb-5 pr-0 pl-0">
<form class="form-horizontal" method="post">
<div class="form-group">
<div class="col-xs-12">
<div class="">
<label for="id_username">E-Mail</label>
<input id="id_username" class="form-control" maxlength="254" name="username" value="" type="text" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="">
<label for="id_password">Password</label>
<input id="id_password" class="form-control" name="password" type="password" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<small class="float-right">
Forgot Password?
</small>
</div>
</div>
<div class="form-group mt-5">
<div class="col-xs-12 col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4 pl-0">
<button class="btn btn-sm btn-block btn-primary" type="submit">Login</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- END Content -->
<!-- END Main Container -->
<!-- Footer -->
<footer class="d-flex justify-content-center mt-auto">
<div class="d-flex justify-content-between col-md-8 col-md-offset-2 mb-3 mt-5">
<!-- Copyright Info -->
<div class="align-left">
<a class="font-weight-bold small kf-blue kf-links" href="#">Link1</a> |
<a class="font-weight-bold small kf-blue kf-links" href="/">Link2</a> |
<a class="font-weight-bold small kf-blue kf-links" href="/">Link3</a>
</div>
<div class="align-right small">
Crafted with Love by <a class="font-weight-bold kf-blue kf-links" href="#" target="_blank">Me</a>
</div>
<!-- END Copyright Info -->
</div>
</footer>
<!-- END Footer -->
</div>
<!-- END Page Container -->
</body>
</html>
codepen updated https://codepen.io/anon/pen/PBpgNN
reminder for boostrap classes https://getbootstrap.com/docs/4.5/utilities/flex/ about sizing see https://getbootstrap.com/docs/4.5/utilities/sizing/
If you want a fixed footer, just add the class fixed-bottom to the footer tag like shown below.
<footer class="fixed-bottom bg-dark">
<div class="text-center">
<p>Footer</p>
</div>
</footer>
First add display: flex; and flex-direction: column; to #page-container.
Now you have "set the stage" for aligning the footer to the bottom. Set its margin-top to auto (by adding the class mt-auto) and you are done;
<div class="d-flex justify-content-center mt-auto">
Content here
</div>
See this codepen.
So this helped me - if someone is still looking for an answer:
on your <HTML>, <body> and your container div add a class h-100 and your footer will stay on the bottom.
Important
One thing I did to remove the extra height is that on my container div I changed the h-100 styling to height: calc(100% - 200px) !important; (where -200px was the height of my navigation and footer)
if you are not using the bootstrap, here is the styling .h-100{height:100% !important}

Tab-Content Layout shows up in other tab

I'm working on a Spring-Boot application using Thymeleaf. Bootstrap4 is the CSS framework I'm using. I'm using nav-tabs for the profile page and the first three tabs don't have any issues but when I click on the address tab and go to any other tab, the content of the Address tab, shows up in the other tabs at the bottom of that tabs content and I cannot figure out why. I'll be including images of the outcome and css of each starting tab. I am hesitant to include the entire page html due to the amount of lines currently (480 total)
<div class="tab-pane fade" id="tab-3" role="tabpanel" th:classappend="${classActiveBilling}? 'in active show'">
<div class="card">
<div class="card-body">
<div class="card-title">
<div class="container">
<div class="row">
<div class="col">
<h4 class="mb-0 align-middle" style="margin-top: 15px;">Billing Information</h4>
</div>
</div>
<div class="row">
<div class="col">
<div class="breadcrumb" style="background-color:transparent;">
<a class="breadcrumb-item active" th:href="#{/listOfCreditCards}" th:style="${listOfCreditCards}? 'color:#6e45e0'">List of Credit Cards</a>
<a class="breadcrumb-item active" th:href="#{/addNewCreditCard}" th:style="${addNewCreditCard}? 'color:#6e45e0'">Add/Update Credit Card</a>
</div>
</div>
</div>
<div class="tab-pane fade" id="tab-4" role="tabpanel" th:classappend="${classActiveShipping}? 'in active show'">
<div class="card">
<div class="card-body">
<div class="card-title">
<div class="container">
<div class="row">
<div class="col">
<h4 class="mb-0 align-middle" style="margin-top: 15px;">Shipping Information</h4>
</div>
</div>
<div class="row">
<div class="col">
<div class="breadcrumb" style="background-color:transparent;">
<a class="breadcrumb-item active" th:href="#{/listOfShippingAddresses}" th:style="${listOfShippingAddresses}? 'color:#6e45e0'">List of Shipping Addresses</a>
<a class="breadcrumb-item active" th:href="#{/addNewShippingAddress}" th:style="${addNewShippingAddress}? 'color:#6e45e0'">Add/Update Shipping Address</a>
</div>
</div>
</div>
The breadcrumbs were the culprit. It was causing the shipping tab to show up in other windows. I just changed it to a button group and get the same effect. I unfortunately could not get the breadcrumbs themselves to work regardless of how many times I worked on the css so just threw it out completely. Semi answer, but thymeleaf is touchy and doesn't always play nice with frameworks.

Bootstrap 4 tab-panes. Change two panes with one nav-link

I'm trying to get two different cards to update their active tab-pane using one nav-link.
Here is my code. As you can see, I have one card that has act info and one that has the corresponding video in it. When I click to see the other act info, I want the video to also change (at the moment there is no second video - it just says 'stuff number 2'
<div class="row pt-5" id="acts">
<div class="col-md-4 offset-md-1">
<div class="card">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#act1" role="tab">Take Five</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#act2" role="tab">Thank You For Your Consideration</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="act1" role="tabpanel">
<div class="card-block">
<h3 class="card-title">Take Five</h3>
<p class="card-text">Do you also have trouble getting out of bed? Working 9 to 5, the same routine every day.. “Take Five” is about one of those days, a light hearted piece full of absurdness and acrobatics. People of all ages can enjoy the 7- minute act, let Ida surprise you!</p>
</div>
</div>
<div class="tab-pane" id="act2" role="tabpanel">
<div class="card-block">
<div class="container">
<div class="row">
<div class="col-md-9">
<h3 class="card-title">Thank You For Your Consideration</h3>
<p class="card-text">What do you write in a letter when you apply for a job? Everybody has been there, behind a computer screen, mind blank. It sounds too pretentious or too insecure. If only they would see the real you. But if that’s a good idea.. An act about struggles that everyone has experienced, brought with humour, brutal honesty and creativity in movement. Ida’s genuine story is a 6 minute text-based circus performance.</p>
</div>
<div class="col-md-3">
<img src="" alt="TYFYC" class="img-fluid img-rounded">
</div>
</div>j
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-5 offset-md-2">
<div class="card">
<div class="tab-content">
<div class="tab-pane active" id="act1" role="tabpanel">
<div class="card-block">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://player.vimeo.com/video/220114759" allowfullscreen></iframe>
</div>
</div>
</div>
<div class="tab-pane" id="act2" role="tabpanel">
Stuff number 2
</div>
</div>
</div>
</div>
</div>
Is there a way to do this without using a javascript .addClass('active')?

Align Semantic UI text menu center

I'm new to Semantic UI, and I'm trying to have some responsive text menu items on top of my page which are aligned to center of the page always. Here's the sample of my code.
<div class="ui text menu">
<a class="blue item" href="#">Home</a>
<a class="blue item" href="#">About</a>
<a class="blue item active" href="#">Contact</a>
</div>
I have tried to use grid based layout and many other approaches that are suggested on the Net, but all of them are related to compact menus which doesn't work on text menus.
Ended up using following code snippet:
<div class="ui relaxed grid">
<div class="five wide column"></div>
<div class="six wide column">
<div class="ui grid text menu">
<div class="five wide column">
<a class="yellow item" href="#">Home</a>
</div>
<div class="five wide column">
<a class="yellow item" href="#">About</a>
</div>
<div class="five wide column">
<a class="yellow item active" href="#">Contact</a>
</div>
</div>
</div>
<div class="five wide column"></div>
</div>
jsFiddle link
Basically, I created a grid wrapper over my menu and also wrap each menu item in a div. That gives flexibility on fixing right and left margins and also add some space if needed between each menu item.

collapse panel in tablet view

I have a toolbar. When I click on it I have many panels appear on the screen as drop-down.
In the tablet view I want all the panels to collapse and When I click on the panel-heading I want the panel-body to open.
I am poor in css can anyone help me.
Here is the code.
<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse in" style="height: auto;">
<div class="panel-body">
<div class="panel panel-info">
<div class="panel-heading">
<a >First heading</a>
</div>
<div class="panel-body">
<ul class="">
<li><a >item1</a></li>
<li><a >item2</a></li>
</ul>
</div>
</div>
</div>
<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse in" style="height: auto;">
<div class="panel-body">
<div class="panel panel-info">
<div class="panel-heading">
<a>second heading</a>
</div>
<div class="panel-body">
<ul class="">
<li><a >item4</a></li>
<li><a >item3</a></li>
</ul>
</div>
</div>
</div>
As you are using bootstrap accordion. You need to remove class in from your panel-collapse div.
Instead of
<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse in" style="height: auto;">
Write
<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse" style="height: auto;">
in is the class, which makes the content panel visible. So if you want all the panels collapse, remove it form every panel container. If you want only one panel to be visible while others should be collapsed, then put it in that panel container only.
Let me know if this helps. :-)
Bootstrap has specialized classes and data-* attributes for these types of tasks.
1) First, in order to make your panel act as an accordion, you need to give:
<a data-toggle="collapse" data-target="#panel1">Heading</a>
where panel1 is the id of your panel-body.
2) Next, since you want your panel-body to be collapsed at first, give the collapse class next to your panel-body:
<div id="panel1" class="panel-body collapse">
Have a look at the demo here to make things clear.
<div class="panel-body columnBody" id="accordion2">
<div class="panel panel-info">
<div class="panel-heading">
<a data-toggle="collapse" data-parent="#accordion" data-target=".Empty">{{item.key}}</a>
<button class="btn navbar-btn displayMobile" data-parent="#accordion2" data-target=".view{{$index}}"><span class="caret"></span></button>
</div>
<div class="panel-body itemList view{{$index}}">
<ul style="margin-bottom: 0px;">
<li ng-repeat="ke in item.values">{{ke}}</li>
</ul>
</div>
</div>
</div>
css code:
#media screen and (min-width: 850px){
.displayMobile{
display: none;
}
.itemList{
display: none;
}
}