Twitter-Bootstrap 3.3.1 - DataTables always horizontal scrollable - css

I've just updated from Bootstrap 3.2.0 to Bootstrap 3.3.1. I'm also using the DataTables-Plugin and therefore, I'm using dataTables.bootstrap.css and dataTables.bootstrap.js, respectively.
With version 3.2.0 I didn't have any problems, so far. With version 3.3.1 all tables are slightly scrollable in the horizontal direction (see screenshot).
I've got the table within a <div class="table-responsive"> tag. So normally, the horizontal scrollbar should be displayed on smaller screens but not by default.
Any ideas?

This works for me
In Bootstrap v3.3.4 bootstrap.min.css .table-responsive {min-height: .01%; overflow-x: auto;}
is causing the problem
So instead of changing in bootstrap core css file (As it is not recommended)
I edit following lines of code in my custom css file to override bootstrap css
.table-responsive {
overflow-x: inherit;
}
This will solve the issue.

The tables produced by DataTables are configured to be responsive already. So you don't need to enclose them in a bootstrap "table-responsive" div.
Your code might look like this:
<div class="table-responsive">
<table class="table" id="myTable">
.... blah blah ...
</table>
</div>
Then later in javascript you make it a responsive DataTables table:
$('#myTable').DataTable({ responsive: true });
This is redundant and causes the extra scroll bar. Just remove the table-responsive div.

Any of the answers is working for me.
I could fix it adding a width="100% !important" to the table.
.table-responsive table{
width: 100% !important;
}

I do need the table responsive class for mobile web responsive. So, what I do is creating a CSS class with #media only like this:
#media only screen and (min-width: 968px) {
/* disable responsive in desktop */
.disable-in-desktop {
overflow-x: inherit;
}
}
Then I call the .disable-in-desktop next to table-responsive, so it looks like:
<div class="table-responsive disable-in-desktop">
Conclusion:
Now, the responsive class will only work on a mobile screen, because I disabled it on the desktop screen. So the horizontal scroll doesn't occur anymore.
Sorry for the bad English language.

I have yet to find a great answer for why this is occurring. It looks like, for me at least, DataTables is creating the table 1-3 pixels wider than the container. This is always yielding an active horizontal scroll bar. I didn't want to disable the ability to have a responsive table at other resolutions or even lock it into certain sizes, so here's my solution:
$('#dataTable').DataTable({
drawCallback: function(settings) {
// fix to remove unnecessary width
let $table = $(this);
let diff = $table.parent().width() - $table.width();
if (diff > 0 && diff < 3) {
$table.width($table.width() - 4);
}
}
});
Now every time the table is resized, it will make sure the table is 4 pixels smaller than the container it is in, but only if it is within 3 pixels of the parent container. This will still allow it to be responsive at smaller screen sizes, but resize the table a few pixels when it is barely oversized.

put this in your custom.css, the datatable auto generate .row is affecting the scroll bar when is autoflow-x..
#example_wrapper .row{
margin-right:0px;
margin-left:-15px;
}

Related

Bootsrap #sidebar-wrapper takes up space in certain browsers when printing

I have an issue when printing from a twitter bootstrap appplication.
https://hod-nav.herokuapp.com/members/H0252#
When trying to use the print button, or just file > print, the #sidebar-wrapper still takes up real estate on printed pages.
This only occurs om PC Safari, Mac Safari, and Mac Firefox.
I'm using BS 3.3.6.
I've done a ton of things.
• My css is set to media: 'all'
• I've played around with BS print style sheets like so...
#media print {
#sidebar-wrapper {
display: none !important;
visibility: hidden !important;
}
• I've added the mysterious class="hidden-print" to the element in question.
• I'm able to hide things that don't need to be printed with print style sheets like the above.
• I've also added additional selectors from the cascade to target the element very specifically.
As you can see from either clicking the print button, or just a basic CTRL/CMD + P, the problem browsers listed above want to keep the 250px+ white space at the left, vs. allowing the main container div with the map in it to print at full width as in other browsers.
Just wondering if anyone else had come across this issue in these browsers or others.
I'm happy to proved additional information.
Thanks in advance for reading and thinking.
Sincerely,
Dick
It's not the #sidebar-wrapper taking up space in the layout, it's the left padding of the main element, which you need to disable on print:
#media print {
#wrapper {
padding-left: 0;
}
}
This needs to be placed at the end of your styles, to override the #wrapper selector inside #media (min-width: 768px). Alternatively, you could use div#wrapper instead of #wrapper and it will apply regardless of its position in the CSS file.
And, by the way, none of these ids have anything to do with Twitter Bootstrap.
Looks like there is padding in your wrapper element ->
#wrapper { padding-left:250px;}

Trying to remove white space without my home slider disappearing

my problem is that i experience white spaces on my mobile version between slider images on the following website: athleteperks.co.uk
I've been told to you use the following code:
}
.swift-slider-outer {
height: auto !important;
}
this code removes the white spaces between my sliders on my homepage, however it removes my header slider on the mobile and desktop versions.
In your CSS you need to remove the following line:
.swift-slider-outer {height: 600px!important;}
it is within your #media (max-width: 768px) media query. This is forcing your slider to be a certain pixel width and is overriding your solution which is .swift-slider-outer { height: auto !important;}
FYI - !important is got great practice. It's always best to try to see what exactly is going wrong first.

Bootstrap hide not work properly

I have a following code :
<div class="row">
<div class="hidden-xs">
<h1>Hello</h1>
</div>
</div>
and I expect it to be invisible when width will be smaller than 480px as it's default value in bootstrap css files. However, using Google Chrome simulator it becomes invisible when I set width smaller than 768 - so it works like hidden-sm. When I change hidden-xs to hidden-xs-down it always stays visible.
What I do wrong ?
First of all you should double or triple check that your page loads jQuery before anything else. After that should follow the Bootstrap's JS and CSS libraries.
Bootstrap's default class hidden-xs should work just fine if the framework is able to load correctly, no changes to any CSS or JS required at any point. I would also like to mention that hidden-xs-down is not Bootstrap standard, and that explains why it does not work.
What comes to the default breakpoints, 768px is actually XS, while 992px is SM and so forth.
In case you want the div to disappear when the width is below 480px, you should create your own class. To do so, just put the following to your CSS:
#media (max-width: 480px)
{
.hidden-xxs { display: none; }
}

I want to hide the logo completely when <767 px rather than make it responsive

I'm pretty new to Wordpress modding.
At the moment, I'm using the Shift Nav plugin and I've set it to appear when viewport < 767px. This means that the original logo is there regardless of viewport size.
From the CSS I know that the class for logo is set for media all. I would like:
media (max-width: 767px) { display:none; }
But I don't know how to override the existing css code. I've tried adding the above CSS to the CSS editor and obviously nothing happens.
I don't understand what appears to be inline css, see here:
The site is here:
www.thegraduated.co.uk/store
Thanks in advance
You have a style attribute of display:inline-block in your html tag. You can use !important to overwrite that.
.site-logo-anchor a img { display: none !important; }

Twitter Bootstrap: Printing select elements

In Chrome twitter bootstrap select elements cause a bug where it looks like the shadows are stretched vertically.
That image is from the Twitter Bootstrap site itself so it looks like a bug with the framework (although I've seen comments in the github repo that they're not too concerned about print issues). I've tried setting all effects classes to none but that doesn't seem to remove the glitch.
I still need Bootstrap for the layout but I guess I could make a custom print version without form styles but I'm hoping there's a quick fix instead.
thanks!
i had the same problem and just rewrote this css rule:
#media print {
* { background: transparent !important; }
}
to:
#media print {
select { background: #fff !important; }
}

Resources