Bootstrap: Firefox does not properly place tables above 767px width - css

I've created a simple web site with a Bootstrap navbar with tabs. Each tab shows a table. (See here.)
This works fine in Chrome 45 and IE 11 on Windows 8.1.
In Firefox however the tables are placed right to the navbar if the window width is greater than 767px.
<div id="content">
<ul class="nav nav-pills nav-tabs nav-justified navbar-header">
<li class="active"> Tab 1
</li>
<li> Tab 2
</li>
</ul>
<div>
<h1>test</h1>
<table class="table table-bordered table-striped table-responsive" id="azubiTable">
<thead>
<tr id="head">
<th>1st col</th>
<th>2nd col</th>
<th>3rd col</th>
</tr>
</thead>
<tbody>
<tr>
<td>1.1</td>
<td>2.1</td>
<td>3.1</td>
</tr>
<tr>
<td>1.2</td>
<td>2.2</td>
<td>3.2</td>
</tr>
</tbody>
</table>
</div>

My best interpretation is that this is a float clearing issue not working correctly in FF.
If you add clear:both to the div that holds the table it works in FF.

Put nav and table inside col-*-12 like this
<div id="content">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<nav>
<ul class="nav nav-pills nav-tabs nav-justified navbar-header">
<li class="active"> Tab 1
</li>
<li> Tab 2
</li>
</ul>
</nav>
</div>
<div class="col-md-12 col-sm-12 col-xs-12">
<table class="table table-bordered table-striped table-responsive" id="azubiTable">
<thead>
<tr id="head">
<th>1st col</th>
<th>2nd col</th>
<th>3rd col</th>
</tr>
</thead>
<tbody>
<tr>
<td>1.1</td>
<td>2.1</td>
<td>3.1</td>
</tr>
<tr>
<td>1.2</td>
<td>2.2</td>
<td>3.2</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Fiddle

Related

list numbering not vertical align with content

I'm trying to implement an ordered list with a collapsible part inside the li elements. The idea is to have some basic information about a given context and by clicking on the link you get further information. The code is working but the numbering (1.) is not vertical-align with the content (Click to collapse) and I don't know how it can implement that properly. I'm not a css guru, so maybe you can help me.
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<ol class="list-group list-group-numbered">
<li class="list-group-item">
<div class="d-flex justify-content-between align-items-start">
<div class="ms-2 me-5">
<div class="fw-bold">
<a aria-expanded="false" aria-controls="collapseExample" data-bs-toggle="collapse"
href="#collapseExample">Click to collpase</a>
</div>
some information
</div>
<div class="ms-2 ms-5 me-auto">
some more information
</div>
<span class="badge bg-primary rounded-pill">42</span>
</div>
<div class="collapse" id="collapseExample">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Foo, Bar</th>
<th>Foobar</th>
<th>FoobarBaz</th>
<th>Baz</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</li>
</ol>
You can make your list-group-item grid (add .d-grid, .grid-template) and make custom grid areas to place inner content to special cells, see Code Snippet CSS part.
Also for shorts in CSS, toggle-button can be wrapped to .grid-template-toggle class and collapse block class list can be extended by .grid-template-collapse.
.grid-template {
grid-template-areas: 'num toggle' 'collapse collapse';
grid-template-columns: min-content 1fr;
}
.grid-template:before {
grid-area: num;
}
.grid-template-toggle {
grid-area: toggle;
}
.grid-template-collapse {
grid-area: collapse;
}
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" />
<ol class="list-group list-group-numbered">
<li class="list-group-item d-grid grid-template">
<div class="d-flex justify-content-between align-items-start grid-template-toggle">
<div class="ms-2 me-5">
<div class="fw-bold">
<a aria-expanded="false" aria-controls="collapseExample" data-bs-toggle="collapse" href="#collapseExample">Click to collpase</a>
</div>
some information
</div>
<div class="ms-2 ms-5 me-auto">
some more information
</div>
<span class="badge bg-primary rounded-pill">42</span>
</div>
<div class="collapse grid-template-collapse" id="collapseExample">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Foo, Bar</th>
<th>Foobar</th>
<th>FoobarBaz</th>
<th>Baz</th>
</tr>
</thead>
<tbody>
<tr>
<td>Some Text</td>
<td>More text text text</td>
<td>More text text text More text text text</td>
<td>More text text text More text text text</td>
<td>More text text text More text text text</td>
</tr>
</tbody>
</table>
</div>
</li>
</ol>
.grid-template {
grid-template-areas: 'num toggle' 'collapse collapse';
grid-template-columns: min-content auto;
}
.grid-template:before {
grid-area: num;
}
.grid-template-toggle {
grid-area: toggle;
}
.grid-template-collapse {
grid-area: collapse;
}
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<ol class="list-group list-group-numbered">
<li class="list-group-item d-grid grid-template">
<div class="d-flex justify-content-between align-items-start grid-template-toggle">
<div class="ms-2 me-5">
<div class="fw-bold">
<a aria-expanded="false" aria-controls="collapseExample" data-bs-toggle="collapse"
href="#collapseExample">Click to collpase</a>
</div>
some information
</div>
<div class="ms-2 ms-5 me-auto">
some more information
</div>
<span class="badge bg-primary rounded-pill">42</span>
</div>
<div class="collapse grid-template-collapse" id="collapseExample">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Foo, Bar</th>
<th>Foobar</th>
<th>FoobarBaz</th>
<th>Baz</th>
</tr>
</thead>
<tbody>
<tr>
<td>Some Text</td>
<td>More text text text</td>
<td>More text text text More text text text</td>
<td>More text text text More text text text</td>
<td>More text text text More text text text</td>
</tr>
</tbody>
</table>
</div>
</li>
</ol>

Bootstrap 4 using sticky and float on divs

I am using Bootstrap 4 with float-left and float-right classes that keep my 2 divs left and right of each other and works great, but I want the right div to be sticky as well, but this doesnt seem to work. I am using position-sticky on the div using float-right
Float class Reference here: Float URL
Sticky class Reference: Position URL
Essentially my HTML looks like this:
<section class="section">
<div class="float-left col-md-8">
<div class="row sameheight-container">
<div class="col-md-12">
#*Form fields, such as input, select etc.*#
</div>
</div>
</div>
<div class="float-right col-md-4 position-sticky">
<div class="row sameheight-container">
<div class="col-md-12">
<div class="card card-block sameheight-item">
<table>
<thead>
<tr>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>3</td>
<td>6</td>
</tr>
<tr>
<td>5</td>
<td>10</td>
<td>50</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
Please note that the first Div has a bunch of form controls, so I have removed that and just put a comment in there.
Is there a way of doing this?
Thanks for any help!

CSS align text so its in straight line

I have split the page in 3 sections
25% width
50% width
25% width
How can i get my menu in straight line after using text-align:right. I don't want to use margin-left cause without using it the web is more responsive to other devices and looks more appealing.
What i expect to get - Imagur Image of expected outcome.
I want menu to start at yellow line.
My current code in JSFiddle - JSFiddle Example
If you're going to be using Bootstrap, you might as well just use the existing grid system that comes with it. In order to left align an element with right aligned text, you can simply float it:
ul {
list-style-type:none;
margin:0;
padding:0;
text-align:right;
float:left;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-3">
<ul>
<li>Home</li>
<li>News</li>
<li>Contact</li>
<li>About</li>
</ul>
</div>
<div class="col-xs-6">
<table>
<thead>
<tr>
<th colspan="2">Firstname</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john#example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary#example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july#example.com</td>
</tr>
</tbody>
</table>
</div>
<div class="col-xs-3">
test
</div>
</div>
</div>
You simply need to add this css code:
.first ul{
text-align:left;
}
Your code would become:
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
#import url('//netdna.bootstrapcdn.com/bootstrap/latest/css/bootstrap-theme.min.css');
.first{
width:25%;
overflow:hidden;
float:left;
text-align:right;
}
.first ul{
text-align:left;
}
.table{
width:50%;
float:left;
}
.three{
width:25%;
float:right;}
<div class="main">
<div class="first">
<ul>
<li>Home</li>
<li>News</li>
<li>Contact</li>
<li>About</li>
</ul>
</div>
<table class="table">
<thead>
<tr>
<th colspan="2">Firstname</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john#example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary#example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july#example.com</td>
</tr>
</tbody>
</table>
<div class="three">
<p>
test</p>
</p>
</div>
</div>
I hope it helps.

Create panel with two columns

I am trying to create a template that has two columns in a panel. I am using plainBootstrap v3.3.7. Below you can find what I tried:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">Overview
</div>
<div class="panel-body">
</div>
<div class="container-fluid">
<div class="col-md-2">
<table class="table">
<thead>
<tr>
<th>
#
</th>
<th>
Product
</th>
<th>
Payment Taken
</th>
<th>
Status
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
1
</td>
<td>
TB - Monthly
</td>
<td>
01/04/2012
</td>
<td>
Default
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-10">
<div class="tabbable" id="tabs-305570">
<ul class="nav nav-tabs">
<li class="active">
<a href="#panel-495769" data-toggle="tab">Section 1
</a>
</li>
<li>
<a href="#panel-207616" data-toggle="tab">Section 2
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="panel-495769">
<p>
I'm in Section 1.
</p>
</div>
<div class="tab-pane" id="panel-207616">
<p>
Howdy, I'm in Section 2.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
However, my panel look like the following on my screen:
As you can see, in my panel the two columns inside overlap.
Any suggestions why my table and the section overlap so much?
I appreciate your replies!
Because you are wrapping a table which is by default not responsive with .col-md-2 which is a responsive class.
So you have to wrap it with .table-responsive ( a bootstrap class for making tables responsive ), check the updated snippet:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">Overview
</div>
<div class="panel-body">
</div>
<div class="container-fluid">
<div class="col-md-2">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>
#
</th>
<th>
Product
</th>
<th>
Payment Taken
</th>
<th>
Status
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
1
</td>
<td>
TB - Monthly
</td>
<td>
01/04/2012
</td>
<td>
Default
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-10">
<div class="tabbable" id="tabs-305570">
<ul class="nav nav-tabs">
<li class="active">
<a href="#panel-495769" data-toggle="tab">Section 1
</a>
</li>
<li>
<a href="#panel-207616" data-toggle="tab">Section 2
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="panel-495769">
<p>
I'm in Section 1.
</p>
</div>
<div class="tab-pane" id="panel-207616">
<p>
Howdy, I'm in Section 2.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Hope this helps :)
The problem is your columns, wrap both the table and the section in <div class="col-md-6">In the bootstrap grid system when you define <div class="col-md-12"></div>, This is a full grid (bootstrap maximum grid) so in order to get two equal columns out of this, you just define two columns with <div class="col-md-6"></div>. Reference
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
Overview
</div>
<div class="panel-body">
</div>
<div class="container-fluid">
<div class="col-md-6">
<table class="table">
<thead>
<tr>
<th>
#
</th>
<th>
Product
</th>
<th>
Payment Taken
</th>
<th>
Status
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
1
</td>
<td>
TB - Monthly
</td>
<td>
01/04/2012
</td>
<td>
Default
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-6">
<div class="tabbable" id="tabs-305570">
<ul class="nav nav-tabs">
<li class="active">
<a href="#panel-495769" data-toggle="tab">
Section 1
</a>
</li>
<li>
<a href="#panel-207616" data-toggle="tab">
Section 2
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="panel-495769">
<p>
I'm in Section 1.
</p>
</div>
<div class="tab-pane" id="panel-207616">
<p>
Howdy, I'm in Section 2.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Note: Run the snippet as Full page

Contents of twitter bootstrap tab are mixing

I'm still new in creating websites using twitter bootstrap. I was planning to have a tab that contains the assessment of a student but the contents of my tabs are mixing even though the id's are correct. For example, the contents of the payment history are seen in the other tabs although I am not missing any opening and closing tags. The values there are still dummy data. Here is the code:
<section id="main-content" " ng-controller="studCtrl">
<section class="wrapper">
<div class="content-panel">
<div class="row mt">
<div class="col-lg-12">
<h2>Student's Assessment</h2>
<ul class="nav nav-pills">
<li class="active">Distribution</li>
<li class="">Miscellaneous Fees</li>
<li class="">Other Fees</li>
<!--<li class="">Installment Fees</li-->
<li class="">Payment History</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="distribution">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
...
</thead>
<tbody>
...
</tbody>
</table>
</div><!--table-responsive-->
</div>
<div class="tab-pane fade" id="misc-fees">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
...
</thead>
<tbody>
...
</tbody>
</table>
</div><!--table-responsive-->
</div>
<div class="tab-pane fade" id="other-fees">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
...
</thead>
<tbody>
...
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="payment-hist">
payment history
</div><!--payment history-->
</div><!-- end of tab content-->
</div><!--col-lg-12-->
</div> <!--row mt-->
</div><!--content-panel-->
</section><!--/wrapper -->
</section> <!--main-content-->
<section id="main-content" " ng-controller="studCtrl">
The code here has one more double quote sign. At first, you should remove the sign.
But in case still not works properly after removing the sign, than I suggest you may check DOM structure using dev tools in browser(chrome/firefox/...).

Resources